//写日志
public static void WriteLog(string Msg)
{
string sDirPath = ".\\log\\";
CreateDir(sDirPath);
string sFilePath = sDirPath + DateTime.Now.ToString("yyyy-MM-dd") + ".log";
try
{
using (StreamWriter sw = File.AppendText(sFilePath))
{
sw.Write(DateTime.Now.ToString("HH-mm-ss") + ":" + Msg + "\r\n");
sw.Flush();
sw.Dispose();
}
}
catch { }
}
//创建日志所在目录
public static void CreateDir(string dirPath)
{
if (!Directory.Exists(dirPath))
{
try
{
Directory.CreateDirectory(dirPath);
}
catch { }
}
}