日期:2014-05-19  浏览次数:20812 次

[10分] 无法读取文本文件内的中文(WinForm)
在桌面新建一个文本文件,里面输入诺干中文字符。然后在   WinForm   的   TextBox   内读取:

StreamReader   sr   =   new   StreamReader( "C:\..\桌面\new.txt ");

string   strEachLine   =   " ";
ArrayList   alText   =   new   ArrayList();

while   (strEachLine   !=   null)
{
        strEachLine   =   sr.ReadLine();
        if   (strEachLine   !=   null)
                alText.Add(strEachLine);
}

foreach   (string   s   in   alText)
{
        txbTextDetail.Text   +=   s;
}

但是显示出来的是乱码,请问如何解决?

------解决方案--------------------
StreamReader sr = new StreamReader( "C:\..\桌面\new.txt ",Encoding.GetEncoding( "GB2312 "));
多个括号
------解决方案--------------------
StreamReader sr = new StreamReader(@ "C:\..\桌面\new.txt ",Encoding.Default);