c#webbrowser编码导航到本地的html(c# webbrowser coding to navigate local to html)
我正在尝试将本地html位置地址放在我的C#应用程序中的Web浏览器中但总是失败。 我现在正在使用调试模式,因此html文件已经复制到我的Debug文件夹中,因为我总是将copy复制到copy to output选项。 以下是我的代码:
string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); string filePath = Path.Combine(appPath, "index.html"); webBrowser1.Navigate(new System.Uri(@"file://"+ filePath));总是会出现这种错误:
An unhandled exception of type 'System.UriFormatException' occurred in System.dll知道出了什么问题吗?
I'm trying to put a local html location address to the web browser in my C# application but always failed. I'm using debug mode now so the html files had already copied into my Debug folder because i put copy always in the copy to output option. Below is my code:
string appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); string filePath = Path.Combine(appPath, "index.html"); webBrowser1.Navigate(new System.Uri(@"file://"+ filePath));There always this error coming out using that way:
An unhandled exception of type 'System.UriFormatException' occurred in System.dllAny idea what went wrong?
最满意答案
它有点不清楚,但试试这个。 希望这可能有所帮助。
webBrowser1.Navigate(new Uri(@"your File Name"))要么
webBrowser1.Navigate(new Uri(AppDomain.CurrentDomain.BaseDirectory == "\\File Name")编辑:可能是这导致错误,
webBrowser1.Navigate(new System.Uri("@" filePath + "file://"));Its a bit unclear but try this out. Hope this may help.
webBrowser1.Navigate(new Uri(@"your File Name"))Or
webBrowser1.Navigate(new Uri(AppDomain.CurrentDomain.BaseDirectory == "\\File Name")Edit: May be this causing error,
webBrowser1.Navigate(new System.Uri("@" filePath + "file://"));更多推荐
发布评论