自己寫的記錄日志,定期刪除日志的方法。
方法比較簡單,記錄一下吧。
WriteLog( strMsg, strPath, path = AppDomain.CurrentDomain.BaseDirectory + (!path.EndsWith()||!path.EndsWith( path+= (! (fileName== fileName = DateTime.Now.ToString()+ (!fileName.EndsWith( fileName+= StreamWriter sw = File.AppendText(path+ sw.WriteLine(, DateTime.Now.ToString( WriteLog( strMsg, fileName = DateTime.Now.ToString()+ DeleteLog( DirectoryInfo dinfor = FileInfo[] files = (FileInfo file (DateTime.Compare(file.CreationTime.AddMonths(),DateTime.Now)< (DateTime.Compare(file.LastWriteTime.AddMonths(),DateTime.Now)< (DateTime.Compare(Convert.ToDateTime(file.Name.Substring(,)),DateTime.Now.AddMonths(-))< }