学点C#7 IO
来源:互联网 发布:如何投诉淘宝店家 编辑:程序博客网 时间:2024/05/18 00:36
文件
可以使用 .NET Framework 的 File 类的方法执行文件 I/O 操作。例如,可以使用 Exists 方法检查文件是否存在。可以使用 Create 方法来创建文件,在此过程中可以选择覆盖现有文件(如下面的代码示例所示),并且可以使用 FileStream 类和BufferedStream 对象来执行读写操作。
lass TestFileIO{ static void Main() { string fileName = "test.txt"; // a sample file name // Delete the file if it exists. if (System.IO.File.Exists(fileName)) { System.IO.File.Delete(fileName); } // Create the file. using (System.IO.FileStream fs = System.IO.File.Create(fileName, 1024)) { // Add some information to the file. byte[] info = new System.Text.UTF8Encoding(true).GetBytes("This is some text in the file."); fs.Write(info, 0, info.Length); } // Open the file and read it back. using (System.IO.StreamReader sr = System.IO.File.OpenText(fileName)) { string s = ""; while ((s = sr.ReadLine()) != null) { System.Console.WriteLine(s); } } }}
- 学点C#7 IO
- 学点C#
- 学点C# 1 数据类型
- 学点C# 4 继承 & 事件
- 学点C#6 安全代码
- 学点C# 2 运算符& 流控制& 循环& 类
- 学点C# 3 方法 & 不确定参数 & 属性 & Struct & 数组
- 学C#
- IO学霸
- C# IO
- 再学java基础(7)java IO 实战 【待续。。。。。】
- 再学java基础(7)java IO 实战
- 决定学点东西
- 踏实学点东西
- 学点什么吧。
- 正经学点东西
- 学点什么?
- 学点英语
- Linq error: Sequence contains no elements
- 基于MFC,在非客户区与客户区利用CButon类创建button
- android json http连接
- Linux设备驱动程序之阻塞/非阻塞IO----等待对列
- 从资源文件中获取版本信息
- 学点C#7 IO
- ARM处理器中常量的理解
- 我脑残实验室Verilog学习笔记1
- 内核驱动的文件操作
- 简单控件的应用(二)—学生管理系统
- 我脑残实验室verilog学习笔记2
- 简单控件的应用(一)—prj计算器
- Linux+Apache+MySQL+PHP5的安装与配置与phpBB2论坛的架设
- Yahoo!团队实践分享:网站性能优化的34条黄金守则(转)