C#文件操作之把字符串取到文本文件及把文本文件读取到字符串中

一.把字符串读取到文本文件中

using (FileStream fs = new FileStream(Path, FileMode.OpenOrCreate))//把json读到一个文本中
{
StreamWriter sw = new StreamWriter(fs);
sw.Write(str);
sw.Close();
}

二。把一个文本文件读取到字符串中

  string    str= File.ReadAllText(path);

posted on 2019-11-17 10:43  开发中123  阅读(2503)  评论(0编辑  收藏  举报

导航