标签:get efault code tin pat pre sum 内容 read
/// <summary>
/// 创建文件
/// </summary>
/// <param name="path">文件路径</param>
/// <param name="content">文件内容</param>
public static void Save(string path, string content)
{
string s = path.Substring(0, path.LastIndexOf(‘\\‘));
Directory.CreateDirectory(s);//如果文件夹不存在就创建它
FileStream fs = new FileStream(
path, FileMode.Create,
FileAccess.ReadWrite,
FileShare.ReadWrite
);
byte[] data = System.Text.Encoding.Default.GetBytes(content);
//开始写入
fs.Write(data, 0, data.Length);
//清空缓冲区、关闭流
fs.Flush();
fs.Close();
}
标签:get efault code tin pat pre sum 内容 read
原文地址:https://www.cnblogs.com/ezhar/p/13029760.html