首页 > 其他 > 详细

文件流读写

时间:2016-09-26 14:21:58      阅读:92      评论:0      收藏:0      [点我收藏+]
1.命名空间
   System.IO
2.五句创建及完成读写操作句子
   FileStream myfs = new FileStream(path,FileMode.Open);//创建读写流,path为路径
   StreamWriter mysw = new StreamWriter(myfs);//创建读写器
   //StreamReader mysr = new StreamReader(myfs);
   mysw.Write(content);//执行写入,content为写入内容
   //String text = mysr.ReadToEnd();
   mysw.Close();//关闭读写器
   myfs.Close();//关闭读写流
 
3.精简为三句
   StreamWrite mysw = new StreamWrite(path);//直接创建读写器,path为路径
   //StreamReader mysr = new StreamReader(path);//读的写法
   //string text = mysr.ReadeToEnd();//读的写法
   mysw.Write(content);//写入,content为写入内容
   mysw.Close();//关闭读写流

文件流读写

原文:http://www.cnblogs.com/wu-tong/p/5908882.html

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