/// <summary> /// 检查文件的大小,文件大于指定的大小(5M),则删除文件 /// </summary> /// <param name="sFileName"></param> public static void CheckFile(string sFileName) { if (LogFileOperation.GetFileSize(sFileName) > MaxFileSize) { LogFileOperation.DeleteFile(sFileName); } }
public static void ShowError(string sFileName, string Procedure, string ErrorDescript) { try { LogFileOperation.CheckFile(sFileName); StreamWriter streamWriter; if (!File.Exists(sFileName)) { streamWriter = File.CreateText(sFileName); } else { streamWriter = File.AppendText(sFileName); } streamWriter.WriteLine("*** Error Encountered " + DateTime.Now.ToString() + "***"); streamWriter.WriteLine("Description: " + ErrorDescript); streamWriter.WriteLine("Procedure: " + Procedure); streamWriter.WriteLine(""); streamWriter.Flush(); streamWriter.Close(); } catch (Exception) { } }
public static void ShowError(string Procedure, string ErrorDescript) { if (LogFileOperation.errorFileName == null || LogFileOperation.errorFileName == "") { LogFileOperation.InitFile(); } LogFileOperation.ShowError(LogFileOperation.errorFileName, Procedure, ErrorDescript); }
public static void SaveLog(string sReport) { if (LogFileOperation.logFileName == null || LogFileOperation.logFileName == "") { LogFileOperation.InitFile(); } LogFileOperation.SaveLog(sReport, LogFileOperation.logFileName); }
public static void SaveLog(string sReport, string sFileName) { try { LogFileOperation.CheckFile(sFileName); StreamWriter streamWriter; if (!File.Exists(sFileName)) { streamWriter = File.CreateText(sFileName); } else { streamWriter = File.AppendText(sFileName); } streamWriter.WriteLine(sReport); streamWriter.Flush(); streamWriter.Close(); } catch (Exception) { } }