/// <summary> /// 记录信息 /// </summary> /// <param name="type">信息类型</param> /// <param name="title">模块</param> /// <param name="msg">信息</param> public static void WriteMsg(LogType type, string title, string msg) { var path = AppDomain.CurrentDomain.BaseDirectory + "/Log"; DeleteOldFiles(path); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = Path.Combine(path, DateTime.Now.ToString("yyyy-MM-dd") + ".txt"); lock (obj) { var fs = new FileStream(path, System.IO.FileMode.Append); var sw = new StreamWriter(fs); sw.WriteLine("=================" + type.GetDescription() + " ===================="); sw.WriteLine("时间:" + DateTime.Now); sw.WriteLine("模块:" + title); sw.WriteLine("Message:" + msg); sw.Close(); fs.Close(); } }