c# webbrowser.documentstream保存html文件 解决gb2312编码 存下后出现乱码的问题
using System.IO;
这段代码会出现乱码 gb2312 编码的网页存下后出现乱码
String path = "d:\\1.html";
StreamReader sr = new StreamReader(webBrowser1.DocumentStream, Encoding.GetEncoding("GBK"));
StreamWriter sw = new StreamWriter(path);
sw.Write(sr.ReadToEnd());
sw.Flush();
sw.Close();
sr.Close();
winform,主要应用与网页抓取时碰到的乱码问题
程序代码
System.IO.StreamReader streamReader = new System.IO.StreamReader(this.webBrowser1.DocumentStream, System.Text.Encoding.GetEncoding("gb2312"));
string strWebBrowserDocument = streamReader.ReadToEnd();
File.WriteAllText("1.html", strWebBrowserDocument,Encoding.UTF8);
string strWebBrowserDocument = streamReader.ReadToEnd();
File.WriteAllText("1.html", strWebBrowserDocument,Encoding.UTF8);
streamReader.Close();