记录一个写日志方法
public static void WriteLog(String msg) { StreamWriter writer = null; try { writer = File.AppendText(Application.StartupPath + @"\Log\" + "xxx.Log"+DateTime.Now.ToString("yyyy-MM-dd")); writer.WriteLine("{0} {1}", DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss"), msg); writer.Flush(); } catch (Exception ex) { throw ex; } finally { if (writer != null) { writer.Close(); } }
}