How to load local *.htm file to WPF WebBroswer with relative path [duplicate]

时光怂恿深爱的人放手 提交于 2020-01-14 22:45:55

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!