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);

猜你喜欢

转载自www.cnblogs.com/zylstu/p/11875582.html