private static void SaveLog(string log,string ex)
{ string strCurPath = AppDomain.CurrentDomain.BaseDirectory; string strErrorLogPath = Path.Combine(strCurPath, "ErrorLog"); string strErrorLogFile = Path.Combine(strErrorLogPath, "SendEmailLog.log"); if (!Directory.Exists(strErrorLogPath)) { Directory.CreateDirectory(strErrorLogPath); } var fs = new FileStream(strErrorLogFile, FileMode.OpenOrCreate); var streamWriter = new StreamWriter(fs); streamWriter.BaseStream.Seek(0, SeekOrigin.End); streamWriter.WriteLine("系统记录时间:[" + DateTime.Now + "]"); streamWriter.WriteLine("事件 :"+log); streamWriter.WriteLine("错误日志:"+ex); streamWriter.WriteLine(""); streamWriter.Flush(); streamWriter.Close(); fs.Close(); }