第一种:

 

        /// <summary>
        /// 向txt文件写入内容
        /// </summary>
        /// <param name="path">txt文件保存的路径,没有就创建,有内容就覆盖。例:"E:\\text.txt"</param>
        /// <param name="contentSrt">要写入的内容</param>
        private void WriteForTxt(string path,string contentSrt)
        {
            FileStream fs = new FileStream(path, FileMode.Append);
            StreamWriter wr = null;
            wr = new StreamWriter(fs);
            wr.WriteLine(contentSrt);
            wr.Close();
        }

 

相关文章:

  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-08-10
  • 2022-12-23
  • 2021-08-07
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案