2011年5月6日

C#中读写文件总结

摘要: 1、使用FileStream读写文件 文件头: using System;using System.Collections.Generic;using System.Text;using System.IO; 读文件核心代码: byte[] byData = new byte[100];char[] charData = new char[1000]; try{FileStream sFile = new FileStream("文件路径",FileMode.Open);sFile.Seek(55, SeekOrigin.Begin);sFile.Read(byData, 阅读全文

posted @ 2011-05-06 22:12 Gelivable【IT随笔】 阅读(774) 评论(2) 推荐(1) 编辑

2011年5月2日

C#中如何读取和写入到文本文件

摘要: 读取和写入文本文件Read a Text File 的这篇文章部分描述如何使用 StreamReader 类来读取文本的文件。Write a Text File (Example 1),和 Write a Text File (Example 2) 在各节说明了如何使用 StreamWriter 类来向文件写入文本。读取文本文件若要打开、 读取,和来关闭文本文件,下面的代码使用 StreamReader 类。您可以将文本文件的路径传递给 StreamReader 构造函数自动打开该文件。ReadLine 方法读取的每一行文本,并读取递增到下一行将文件指针。当 ReadLine 方法到达文件结尾 阅读全文

posted @ 2011-05-02 09:21 Gelivable【IT随笔】 阅读(2980) 评论(0) 推荐(0) 编辑

导航