//打开文件到流 FileStream fs=new FileStream(path,FileMode.Open,FileAccess.ReadWrite); //写文件流的方法 StreamWriter sw =new StreamWriter(fs); //清空文档 fs.SetLength(0); sw.WriteLine("要写入的内容"); //清空缓存,并将所有缓冲写入基础流 sw.Flush(); sw.Close(); fs.Close();
//打开文件到流 FileStream fs=new FileStream(path,FileMode.Open,FileAccess.ReadWrite); //写文件流的方法 StreamWriter sw =new StreamWriter(fs); //清空文档 fs.SetLength(0); sw.WriteLine("要写入的内容"); //清空缓存,并将所有缓冲写入基础流 sw.Flush(); sw.Close(); fs.Close();
转载于:https://www.cnblogs.com/DONET-LC/p/6807713.html