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里写空

  

posted @ 2013-05-27 18:03  乡土的味道  阅读(315)  评论(0编辑  收藏  举报