/// <summary> /// 输出指定信息到文本文件 /// </summary> /// <param name="msg">输出信息</param> public static void WriteMessage(string msg) { using (FileStream fs = new FileStream(@"d: est.txt", FileMode.OpenOrCreate, FileAccess.Write)) { using (StreamWriter sw = new StreamWriter(fs)) { sw.BaseStream.Seek(0, SeekOrigin.End); sw.WriteLine("{0} ", msg, DateTime.Now); sw.Flush(); } } }
引用:https://www.cnblogs.com/dansediao/p/6605141.html