public class FaceLog { public static void AppendInfoLog(string errMsg) { try { string Folder = Main.Instance.AppPath + "\\Logs\\"; string fileName = Folder + "Info_" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; if (!System.IO.Directory.Exists(Folder)) System.IO.Directory.CreateDirectory(Folder); if (!File.Exists(fileName)) System.IO.File.Create(fileName); using (TextWriter fs = new StreamWriter(fileName, true)) { fs.WriteLine("--------------------------" + DateTime.Now.ToString() + "----------------------------------------"); fs.WriteLine(errMsg); fs.WriteLine(""); fs.WriteLine(""); fs.Close(); fs.Dispose(); } } catch { } } public static void AppendErrorLog(string errMsg) { try { string Folder = Main.Instance.AppPath + "\\Logs\\"; string fileName = Folder + "Error_" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; if (!System.IO.Directory.Exists(Folder)) System.IO.Directory.CreateDirectory(Folder); if (!File.Exists(fileName)) System.IO.File.Create(fileName); using (TextWriter fs = new StreamWriter(fileName, true)) { fs.WriteLine("--------------------------" + DateTime.Now.ToString() + "----------------------------------------"); fs.WriteLine(errMsg); fs.WriteLine(""); fs.WriteLine(""); fs.Close(); fs.Dispose(); } } catch { } } }
时间: 2024-12-28 17:39:53