public void SaveToLog(string strTxt)
{
try
{
DateTime dt = DateTime.Now;
if (Directory.Exists( Application.StartupPath + "\\Log") == false)//如果不存在就创建file文件夹
{
Directory.CreateDirectory( Application.StartupPath + "\\Log");
}
string strLogFileName = Application.StartupPath + "\\Log\\Log(" + dt.Year + "-" + dt.Month + "-" + dt.Day + ").txt";
StreamWriter sw = new StreamWriter(strLogFileName, true);
sw.WriteLine("Apr " + DateTime.Now.ToString() + ":");
sw.WriteLine(strTxt);
sw.Close();
}
catch (Exception exc)
{
string s = exc.Message;
}
}
Log
最新推荐文章于 2023-01-10 13:46:17 发布