You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
1.0 KiB

2 years ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.IO;
  7. using System.Configuration;
  8. namespace ManagementSystem.Utility
  9. {
  10. class ErrorHandler
  11. {
  12. public static void WriteErrorLog(string strProgramName, Exception ex)
  13. {
  14. //產生錯誤訊息檔名
  15. string[] strExObj = new string[5];
  16. strExObj[0] = "檔案名稱:" + strProgramName;
  17. strExObj[1] = "錯誤時間:" + DateTime.Now.ToString();
  18. strExObj[2] = "錯誤說明:";
  19. strExObj[3] = ex.ToString();
  20. strExObj[4] = "===========================================================================================================================";
  21. string strErrorPath = ConfigurationManager.AppSettings["ErrorFilePath"] + "Err" + DateTime.Now.ToShortDateString().Replace("/","-") + ".txt";
  22. UtilityClass.WriteFile(strErrorPath, strExObj);
  23. }
  24. }
  25. }