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();
转载于:https://www.cnblogs.com/swarb/archive/2012/05/24/9924415.html