日期:2014-05-20 浏览次数:21165 次
using (FileStream fsteam = File.OpenRead(@"D:\tmp\1.txt")) { byte[] buff = new byte[fsteam.Length]; fsteam.Read(buff, 0, buff.Length); string str = Encoding.GetEncoding("GB18030").GetString(buff); //string str = Encoding.GetEncoding("gb2312").GetString(buff); Console.WriteLine(str); }
------解决方案--------------------
StreamReader sr = new StreamReader("x:\\xx.txt",Encoding.GetEncoding("GB18030"));
string content = sr.ReadToEnd();