StreamReader sr;
string line;
sr = new StreamReader("d:/t.txt");
line = sr.ReadLine();
MessageBox.Show(line);
我在t.txt 写上 卧室在 三个字
为什么在messagebox里总是空 没有汉字啊?

解决方案 »

  1.   

    new StreamReader("d:/t.txt"); 
    少了Encoding.无法判断文件编码
      

  2.   

    不会有问题。会用默认编码的。编码没变过,应该不会有问题。不会是 d:/t.txt 的问题吧?d:\\t.txt
      

  3.   

    文件流肯定没问题 因为我把t.txt里的汉字变成英文messagebox 里就能正常显示
      

  4.   

    StreamReader sr = new StreamReader(@"d:\dd.txt",System.Text.Encoding.GetEncoding("GB2312"));
      

  5.   

    messagebox. show( System.IO.File.ReadAllText(Application.StartupPath & "\1.txt", System.Text.Encoding.GetEncoding("gb2312")))