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); }
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);
}