【Asp.Net】StreamReader类read方法使用
2017-05-01 11:31
239 查看
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace _297 { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { using (FileStream fs=new FileStream(Server.MapPath("Text1.txt"),FileMode.Open,FileAccess.Read)) { StreamReader sr = new StreamReader(fs, true); char[] bufferChar = new char[10]; sr.Read(bufferChar, 5, 5); foreach(char c in bufferChar) { Response.Write(c); } } } } }
sr.Read(bufferChar, 5, 5); 此方法的构造函数是sr.read(char[] buffer,int index,int count),index是指buffer缓存的起始位置,并不是sr中字符的位置。
参考链接:
http://blog.csdn.net/nn179/article/details/12832677
相关文章推荐
- 在ASP.Net 中使用实现windows登陆的方法. (轉自tainkai的專欄.http://blog.csdn.net/tainkai)
- 简介使用ASP.NET访问Oracle数据库的方法
- 平时在做ASP.NET项目里经常使用的一些函数和方法
- 简介使用ASP.NET访问Oracle数据库的方法
- 平时在做ASP.NET项目里经常使用的一些函数和方法
- 简介使用ASP.NET访问Oracle数据库的方法
- 将图片插入数据库并使用asp.net读取出来的正确方法
- MattPowell介绍了如何在服务器端使用异步Web方法,来创建高性能的 Microsoft ASP.NET Web 服务
- 使用 NDoc 对 asp.net (Web) 项目产生文档的方法
- 在Asp.Net中使用SmtpMail发送邮件的方法
- 在ASP.Net 中使用实现windows登陆的方法.
- 如何在ASP.NET中制作Web用户自定义控件,并在aspx页面中使用它的方法和属性?
- 平时在做ASP.NET项目里经常使用的一些函数和方法
- ASP.NET中使用Server.Transfer()方法在页间传值
- "ASP.NET 管理实用工具"使用方法
- [导入]关于在ASP.NET中使用MD5加密的方法
- 简介使用ASP.NET访问Oracle数据库的方法
- 平时在做ASP.NET项目里经常使用的一些函数和方法
- asp.net报表解决方法(第一次使用cnblogs的blog)
- asp.net中的cookie使用方法