c# streamwriter

2024-12-03 17:41:14
推荐回答(3个)
回答1:

编码方式
FileStream fs = new FileStream("D:\\text.txt", FileMode.Append);
StreamWriter sw = new StreamWriter(fs,Encoding.Defaut);
sw.WriteLine("Hello");
//最后记得关闭

sw.Close();
fs.Close();

回答2:

用完许关闭流,加sw.Close();

回答3:

sw.Flush();