首页 新闻 赞助 找找看

使用WebBrowser读取mht文件,读取的不完整,求助啊。

0
悬赏园豆:20 [已解决问题] 解决于 2018-01-03 13:44

mht文件是本地的,不会是网上的.

// 读取固定文件存放路径
string fixed_path = ConfigHelper.Get("FormFilePath");
// 组合完整路径
string file_path = fixed_path + "ddd\\16C1BC09F75AF10F482581FA000CC096.mht";
// html文件名
string temp_file = file_path.Replace(".mht", ".html");
// 创建WebBrowser对象
WebBrowser webBrowserObj = new WebBrowser();
// 加载
webBrowserObj.Url = new Uri(file_path);
// 避免乱码
System.IO.StreamReader getReader = new System.IO.StreamReader(webBrowserObj.DocumentStream, System.Text.Encoding.GetEncoding("gb2312"));
// 
string content = getReader.ReadToEnd();
this.textHtml.Text = content;
// 创建html文件
IOHelper.WriteFile(temp_file, content, false);

只能读取十分之一的内容。。mht有151KB,实在不知道哪里错误了,mht文件都是本地的

快乐的langYa的主页 快乐的langYa | 菜鸟二级 | 园豆:321
提问于:2018-01-03 11:08
< >
分享
最佳答案
0

参考 C# 打印webBrowser打开的页面 中的代码,在 DocumentCompleted 事件中读取

webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(WebBrowser_DocumentCompleted);
收获园豆:15
dudu | 高人七级 |园豆:31075 | 2018-01-03 13:42

谢谢,可以了。

快乐的langYa | 园豆:321 (菜鸟二级) | 2018-01-03 13:44
其他回答(1)
0

是里面的图片读取不到么?

收获园豆:5
Daniel Cai | 园豆:10424 (专家六级) | 2018-01-03 12:04
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册