问题
Possible Duplicate:
Load local HTML file in a C# WebBrowser
I´m creating program in C# (VS 2010), and I´d like to show help file. I created file help.htm. This file is included to solution in help directory. And I´d like this htm file load to webBroswer in Dialog. But there is a probelm, when I try to use relative path.
HelpWindow helpwin = new HelpWindow(); //creating new window
Uri helpUri = new Uri ("help\\pm_view.htm",UriKind.RelativeOrAbsolute); //setting path
helpwin.webBrowser.Navigate(helpUri); //navigating webBroswer
After that, i get error: Relative URIs are not allowed. Parameter name: source
There is my C# solution schema in picture:
Please can anyone help?!
Thanks a lot!
回答1:
Have you tried using
Path.GetFullPath(YourRelativePath)
as per this answer: Answer on relative paths in WPF?
回答2:
I wrote a short article about this: WebBrowserEx: WinForms WebBrowser + HTTP Server
The code is for WinForms, but you could modify it for WPF.
来源:https://stackoverflow.com/questions/10572325/how-to-load-local-htm-file-to-wpf-webbroswer-with-relative-path