コード例 #1
0
 /// <summary>
 /// 检查文件的大小,文件大于指定的大小(5M),则删除文件
 /// </summary>
 /// <param name="sFileName"></param>
 public static void CheckFile(string sFileName)
 {
     if (LogFileOperation.GetFileSize(sFileName) > MaxFileSize)
     {
         LogFileOperation.DeleteFile(sFileName);
     }
 }
コード例 #2
0
 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)
     {
     }
 }
コード例 #3
0
 public static void ShowError(string Procedure, string ErrorDescript)
 {
     if (LogFileOperation.errorFileName == null || LogFileOperation.errorFileName == "")
     {
         LogFileOperation.InitFile();
     }
     LogFileOperation.ShowError(LogFileOperation.errorFileName, Procedure, ErrorDescript);
 }
コード例 #4
0
 public static void SaveLog(string sReport)
 {
     if (LogFileOperation.logFileName == null || LogFileOperation.logFileName == "")
     {
         LogFileOperation.InitFile();
     }
     LogFileOperation.SaveLog(sReport, LogFileOperation.logFileName);
 }
コード例 #5
0
        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)
            {
            }
        }