- Published on
C# - Simple StreamWriter and StreamReader
StreamWriter
string s = "abc 中文字 132";
StreamWriter sw = new StreamWriter(@"Z:\test.txt", false);
sw.Write(s);
sw.Close();
StreamReader
StreamReader sr = new StreamReader(@"Z:\test.txt");
string s = sr.ReadToEnd();
sr.Close();