写日志
public void Log(string message) { try { string LogPath = @"C:\CRMLog\"; if (!Directory.Exists(LogPath)) { Directory.CreateDirectory(LogPath); } string filePath = LogPath + DateTime.Now.ToString("yyyy-MM-dd") + "_delete.log"; using (FileStream stream = File.Open(filePath, FileMode.Append, FileAccess.Write, FileShare.Write)) { using (StreamWriter sw = new StreamWriter(stream)) { sw.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")); sw.WriteLine(message); sw.Flush(); } } } catch { } }