C# 制定内容写入文件(HTML,txt等)

//引用using

using System.IO;
using System.Text;

//写入方法

        public void writeToHtml(string fileName, string path, string content)
        {
            string fileAndName = path + "/" + fileName;
            using (FileStream fs = new FileStream(fileAndName, FileMode.Create))
            {
                using (StreamWriter w = new StreamWriter(fs, Encoding.UTF8))
                {
                    w.WriteLine(content);
                }
            }
        }

  

原文地址:https://www.cnblogs.com/tangpeng97/p/7838004.html