string FILE_NAME = "c:/B004.txt";
StreamReader sr = new StreamReader(FILE_NAME,Encoding.GetEncoding("GB2312"),true);
string input = sr.ReadToEnd();sr并没有读出所有的内容。它认为就到了文件的结尾了.

解决方案 »

  1.   

    你试试下面的代码!
    FileStream fsMyfile = new FileStream("myfile.txt" , FileMode.Open, FileAccess.ReadWrite); 
    StreamReader srMyfile= new StreamReader(fsMyfile); 
    // 把文件指针重新定位到文件的开始
    srMyfile.BaseStream.Seek(0, SeekOrigin.Begin); 
    // 打印文件文本内容
    string s1;
    while((s1 = srMyfile.ReadLine())!=null)
    {
         Console.WriteLine(s1);
    }
    srMyfile.Close();
    fsMyfile.Close();
    记得关闭文件阿!
      

  2.   

    StreamReader sr = new StreamReader(FILE_NAME,Encoding.default);
    试试看
      

  3.   

    用ReadLine一行一行读吧 要不把结束符号替换掉?结束符号到底是什么/