一、代码积累
var path = "E:\test.txt"; FileStream fs = new FileStream(path, FileMode.Create); StreamWriter sw = new StreamWriter(fs); //开始写入 sw.Write(item.DataId); sw.Write('hello world!'); //清空缓冲区 sw.Flush(); //关闭流 sw.Close(); fs.Close();
需要添加命名空间:using System.IO;