用webbroswer控件获取网页内容时,中文经常会出现乱码,因为.net用的编码格式unicode,但是网页有的是gb2312,月的用的是utf-8,这就导致中文乱码。解决办法:
System.IO.StreamReader getReader = new System.IO.StreamReader(this.Webbroswer.DocumentStream, System.Text.Encoding.GetEncoding("UTF-8")); //这里的utf-8,可以换成其他的编码格式,也可以用 this.webBrowser.Document.Encoding
string gethtml = getReader.ReadToEnd();
搞定。