如何加载WebBrowser控件本地HTML页面中的C# [英] How to load local HTML pages in WebBrowser control in C#
本文介绍了如何加载WebBrowser控件本地HTML页面中的C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的本地HTML网页数量。我想显示在Web浏览器中控制这些地方的HTML页面。当我添加新的页面应该得到追加到previous页。
I have number of local HTML pages. I want to display these local HTML pages in Web browser control. When I add new page it should get append to previous page.
下面是示例code的设置网址
Here is the sample code for the setting Url
for( int i=0; i<=filecount; i++)
web-browser.Url = new Uri(filepath[i]);
但在运行时它显示文件下载弹出和Web浏览器是空的。
But during run time its showing the File Download pop up and web browser is empty.
推荐答案
您可以加载一个页面
FileStream source = new FileStream(filepath, FileMode.Open, FileAccess.Read);
webBrowser1.DocumentStream = source;
甚至像
string html = File.ReadAllText(filepath);
webBrowser1.DocumentText = html;
但如果你有图像,在相对路径CSS或JS,用
But if you have images, css or js in the relative paths, use
Uri uri = new Uri(filepath);
webBrowser1.Navigate(uri);
这篇关于如何加载WebBrowser控件本地HTML页面中的C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文