StreamReader和StreamWriter(字符)
2016-02-24 20:58
471 查看
StreamReader和StreamWriter用于操作文本文件
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { //使用StreamReader来读取一个文本文件 using (StreamReader sr = new StreamReader(@"C:\Users\SpringRain\Desktop\抽象类特点.txt", Encoding.Default)) { while (!sr.EndOfStream) { Console.WriteLine(sr.ReadLine()); } } //使用StreamWriter来写入一个文本文件 using (StreamWriter sw = new StreamWriter(@"C:\Users\SpringRain\Desktop\newnew.txt", true)) { sw.Write("看我有木有把你覆盖掉"); } Console.WriteLine("OK"); Console.ReadKey(); } } }
相关文章推荐
- 分享一个自己的 VS2010 C++配色方案 主题
- .NET笔试题集(五)
- TV测试中的按键长按操作模拟
- uboot的介绍
- https://projecteuler.net/problem=8
- 1039. Course List for Student (25)
- 235. Lowest Common Ancestor of a Binary Search Tree
- Excel宏-超链接常用脚本
- 阅读收藏夹
- 算法精讲学习笔记 链表
- Yii2-权限控制RBAC-应用篇(二)
- 【6-5】HBASE的Java接口
- 通过源码安装Redis
- LeetCode -- Minimum Path Sum
- 《代码整洁之道》读书笔记
- 替换空格
- C语言 int &a
- hdu3487 splay树
- POJ 1905 Expanding Rods 二分加数学公式的推导
- hdu3487 splay树