自己平时感觉好用的封装的常见方法-未完待续

写入创建txt文件

/// <summary>
    /// 生成文件
    /// </summary>
    /// <param name="content">文件内容</param>
    public void CreatePage(string content, string filename)
    {
        try
        {
            if (!System.IO.Directory.Exists(filename.Substring(0, filename.LastIndexOf(\'/\'))))
            {
                System.IO.Directory.CreateDirectory(filename.Substring(0, filename.LastIndexOf(\'/\')));
            }
            FileStream fs = new FileStream(filename, FileMode.Create);
            StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.GetEncoding("GB2312"));
            sw.WriteLine(content);
            sw.Flush();
            sw.Close();

            bool result =
版权声明:本文为taotaoyangyan原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/taotaoyangyan/p/4819730.html