还有设置StreamReader的读取时的方式为gb2312谢过

解决方案 »

  1.   

    string path = @"c:\MyTest.txt";string str="";
    using (StreamReader sr = new StreamReader(path,System.Text.Encoding.GetEncoding("GB2312"))) 
    {
         str=sr.ReadToEnd();
    }
    using (StreamWriter sw = new StreamWriter(path,System.Text.Encoding.GetEncoding("GB2312"))) 
    {
                sw.Write("This is the ");           
                sw.WriteLine(DateTime.Now);
    }