记录日常日志(文件名以日期命名)
public static void WriteLog() { if (!System.IO.Directory.Exists("Log")) { System.IO.Directory.CreateDirectory("Log"); } string fileName = string.Format(@"Log\Log_{0}.log", DateTime.Now.ToString("yyyy-MM-dd")); System.IO.File.AppendAllText(fileName, string.Format("\r\n------- {0} --------\r\n", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); System.IO.File.AppendAllText(fileName, "日志内容"); }