C# TXT写入数据
public static string MMSTxtQuickMark = System.Configuration.ConfigurationManager.AppSettings["MMSTxtQuickMark"]; /// <summary> /// 向文件夹TXT写入文字 /// </summary> /// <param name="msg"></param> private void TestAppend(string msg) { string path = MMSTxtQuickMark; //路径 从webconfig取出 FileStream fs = new FileStream(path, FileMode.Append); StreamWriter sw = new StreamWriter(fs, Encoding.GetEncoding("GB2312")); sw.WriteLine(msg ); sw.Close(); fs.Close(); }
System.IO.File.WriteAllText(MMSTxtQuickMark, string.Empty); //把TXT里写空