C#为txt文件追加文字并换行
string path= System.Windows.Forms.Application.StartupPath + "\\ErrorLog\\"+fileName +".txt";
if (!File.Exists(path))
{
FileInfo myfile = new FileInfo(path);
FileStream fs = myfile.Create();
fs.Close();
}
StreamWriter sw = File.AppendText(path);
sw.WriteLine(errorMsg);
sw.Flush();
sw.Close();
- 上一篇 »java 文件输出 换行
- 下一篇 »PHP读取txt文件的内容并赋值给数组的代码