IE webbrowsercontrol losing .. in file path of URL
When a IE browser control is embedded in a winform a开发者_运维百科nd the link on a page contains a relative file path the URL coming into the callback for the navigate event seems to lose "file:///../../dir/file.htm
" and becomes "file:///dir/file.htm
"
private void OnNavigating(object sender, WebBrowserNavigatingEventArgs e)
{
// looking at e.Url to see what happens
}
Has anyone seen similar problems? Any suggestions?
I think your URL is incorrect. If you want a relative path, just specify a relative path, such as ../../dir/file.htm
. If your URL starts with a protocol specifier, then it's an absolute URL, where a ..
at the start is superfluous, since you're already starting at the root of the file system.
file:///../../dir/file.htm
is not a valid url. By definition the URI cannot be relative.
(Hence the 'U' in URI/URL)
I agree with other suggestions here: don't use file:///, just specify the relative path directly.
精彩评论