首页 > Windows开发 > 详细

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

时间:2019-11-17 11:58:49      阅读:291      评论:0      收藏:0      [点我收藏+]

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

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

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

  string    str= File.ReadAllText(path);

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

原文:https://www.cnblogs.com/zylstu/p/11875582.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!