自己平时感觉好用的封装的常见方法-未完待续 - 桃桃养颜
写入创建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 =