C# 保存文本txt 保存日志 保存.txt
public void SaveFile() { string stream = null; if (File.Exists("log.txt")) { StreamReader reader = new StreamReader("log.txt"); stream = reader.ReadToEnd(); reader.Close(); } FileStream fs = new FileStream("log.txt", FileMode.OpenOrCreate); StreamWriter sw = new StreamWriter(fs); sw.WriteLine(stream); sw.WriteLine(); sw.WriteLine("***********************************************************************"); sw.WriteLine(DateTime.Now); sw.WriteLine("ADD:"); sw.WriteLine("1: 10234 刘辉 55 美国二部 11 美国第一事业部 224 北京公司"); sw.WriteLine("2: 10234 刘辉 55 美国二部 11 美国第一事业部 224 北京公司"); sw.WriteLine("UPDATE:"); sw.WriteLine("1: 10234 刘辉 55 美国二部 11 美国第一事业部 224 北京公司 改为 10234 刘辉 55 美国二部 11 美国第一事业部 224 北京公司"); sw.WriteLine("1: 10234 刘辉 55 美国二部 11 美国第一事业部 224 北京公司 改为 10234 刘辉 55 美国二部 11 美国第一事业部 224 北京公司"); sw.Close(); fs.Close(); }
本文来自博客园,作者:程序猿网友666,转载请注明原文链接:https://www.cnblogs.com/chenghu/archive/2013/05/30/3108341.html

浙公网安备 33010602011771号