惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
Google Developers Blog
博客园 - 三生石上(FineUI控件)
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
MongoDB | Blog
MongoDB | Blog
小众软件
小众软件
Y
Y Combinator Blog
博客园 - 聂微东
Google DeepMind News
Google DeepMind News
D
Docker
罗磊的独立博客
Microsoft Security Blog
Microsoft Security Blog
D
DataBreaches.Net
B
Blog
Vercel News
Vercel News
Recent Announcements
Recent Announcements
GbyAI
GbyAI
阮一峰的网络日志
阮一峰的网络日志
T
The Blog of Author Tim Ferriss
H
Hackread – Cybersecurity News, Data Breaches, AI and More
P
Proofpoint News Feed
酷 壳 – CoolShell
酷 壳 – CoolShell
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Microsoft Azure Blog
Microsoft Azure Blog
宝玉的分享
宝玉的分享

博客园 - 妖居

ASP.NET MVC Tips #2 - 令人混乱的Get、Post、Return View和Return Redirect ASP.NET MVC Tips #1 - 支持上传文件的ModelBinder How to migrate MsSql database to MySql Windows Workflow Foundation 使用小例 使用异步委托解决Windows Application应用Duplex Service时出现的Deadlock问题 字节数组、数值和十六进制字符串的转换 表格化固定长、CSV文件编辑器工具 iMatrixitor 发布 Getting Started With LINQ in Visual Basic (翻译 + 评论) 使用接口实现附带插件功能的程序 两个简单方法加速DataGridView 使用.NET自带的功能制作简单的注册码 《Introducing Visual Basic 2005》中看到的一些VB2005的新特性 VB.NET函数的返回值问题(从CSDN论坛一个问题想到的) Add-in and Automation Development In VB.NET 2003 (Finished) Add-in and Automation Development In VB.NET 2003 (8) 模拟IE地址栏的TextBox小控件 Add-in and Automation Development in VB.NET 2003 (6-7) 在WinXP环境下显示XP风格的控件 Add-in and Automation Development In VB.NET 2003 (5)
不是说“Peek 不会更改 StreamReader 的当前位置”么。MS骗人的!
妖居 · 2005-09-27 · via 博客园 - 妖居

在MSDN里面看到关于StreamReader.Peek 方法的解释,备注里面说
Peek 不会更改 StreamReader 的当前位置。如果当前没有更多的可用字符,则返回值为 -1。

但是假设C:\CMSG.LOG文件一行内容超过1024字节后,运行下面的程序就会发现Peek之后,
Position变成了1024了。但是此后如果再运行Peek就没有问题了,Position不会改变。
难道MSDN说的是错的???

代码:
        Dim fs As New IO.FileStream("C:\CMSG.LOG", IO.FileMode.Open, IO.FileAccess.Read)
        Dim sr As New IO.StreamReader(fs, System.Text.Encoding.GetEncoding(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ANSICodePage))
        MsgBox("Position before peek: " & sr.BaseStream.Position)
        sr.Peek()
        MsgBox("Position after peek: " & sr.BaseStream.Position)
        sr.Close()
        fs.Close()

To dudu:这个问题我在CSDN上面问了,但是没有人回。暂借首页问一下。