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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Configuration;
namespace ManagementSystem.Utility
{
class ErrorHandler
{
public static void WriteErrorLog(string strProgramName, Exception ex)
{
//產生錯誤訊息檔名
string[] strExObj = new string[5];
strExObj[0] = "檔案名稱:" + strProgramName;
strExObj[1] = "錯誤時間:" + DateTime.Now.ToString();
strExObj[2] = "錯誤說明:";
strExObj[3] = ex.ToString();
strExObj[4] = "===========================================================================================================================";
string strErrorPath = ConfigurationManager.AppSettings["ErrorFilePath"] + "Err" + DateTime.Now.ToShortDateString().Replace("/","-") + ".txt";
UtilityClass.WriteFile(strErrorPath, strExObj);
}
}
}