public static void ErrLog(string errMsg) { string Path = ""; Path = System.AppDomain.CurrentDomain.BaseDirectory + "LogFile" + "_" + DateTime.Now.ToString("yyyyMMdd") + ".txt"; FileStream fs = new FileStream(Path, FileMode.OpenOrCreate, FileAccess.Write); StreamWriter m_streamWriter = new StreamWriter(fs); m_streamWriter.BaseStream.Seek(0, SeekOrigin.End); m_streamWriter.WriteLine(DateTime.Now.ToString() + ":" + errMsg.Replace("\r\n", "") + "\n"); m_streamWriter.Flush(); m_streamWriter.Close(); fs.Close(); GC.Collect(); }