无缓冲的文件IO? [英] unbuffered file IO?

查看:83
本文介绍了无缓冲的文件IO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

框架中是否有一个类允许我以无缓冲的方式从文件中读取文本

?也就是说,我希望能够以与StreamReader.ReadLine()相同的方式读取

中的行,但我还需要能够准确地读取
获取该行文件中的位置。由于
StreamReader和FileStream都是缓冲数据,因此你不能将

BaseStream.Position与你从流中读取的数据等同起来。


Lee Crabtree

Is there a class in the framework that allows me read text from a file
in an unbuffered manner? That is, I''d like to be able to read lines in
the same manner as StreamReader.ReadLine(), but I also need to be able
to accurately get the position in the file of that line. Since
StreamReader and FileStream both buffer data, you can''t equate the
BaseStream.Position with the data you''re reading from the stream.

Lee Crabtree

推荐答案

我认为框架中没有,但你可以轻松创建一个。


扩展TextReader创建自己的阅读器并使用BufferedStream来缓冲基本流(bufferedstream'的Position属性根据缓冲区返回

位置,这样你就可以得到准确的位置。) 。


" Lee Crabtree" < lc ******* @ goisi.comwrote in message

news:Ok ************** @ TK2MSFTNGP02.phx.gbl ...
I don''t think there is in framework but you can easily create one.

Extend "TextReader" to create your own reader and use BufferedStream for
buffering the base stream (bufferedstream''s Position property returns the
position based on buffers so you can get accurate position.).

"Lee Crabtree" <lc*******@goisi.comwrote in message
news:Ok**************@TK2MSFTNGP02.phx.gbl...

框架中是否有一个类允许我以无缓冲的方式从

中的文件中读取文本?也就是说,我希望能够以与StreamReader.ReadLine()相同的方式读取

中的行,但我还需要能够准确地确定
获取该行文件中的位置。由于StreamReader

和FileStream都是缓冲数据,因此你不能将BaseStream.Position

等同于你从流中读取的数据。


Lee Crabtree
Is there a class in the framework that allows me read text from a file in
an unbuffered manner? That is, I''d like to be able to read lines in the
same manner as StreamReader.ReadLine(), but I also need to be able to
accurately get the position in the file of that line. Since StreamReader
and FileStream both buffer data, you can''t equate the BaseStream.Position
with the data you''re reading from the stream.

Lee Crabtree


我完成了一个类,我根据某些结果存储所有行偏移

of line ....用100万行加上行文件进行测试工作漂亮..你好了b $ b可以查看看看我在做什么,让你自己上课

我做什么

我有一个LONG []数组用于存储行偏移,在我读取

文件之前创建...所以没有很多调整大小(复制)1创建数组

和1调整大小(复制)完成后读取行Offsetts


我还是c#的新手所以评论在代码上也欢迎...

回复我会在这里粘贴代码

MJ

" Lee Crabtree" < lc ******* @ goisi.comwrote in message

news:Ok ************** @ TK2MSFTNGP02.phx.gbl ...
Im Finishing up a class where i store all the line offsets based on some end
of line....been testing it with 1million plus row files works pretty ..you
can prob look and see what im doing and make ur own class

What i do
I have a LONG[] array for storing line offsets, createt before i read the
file... so there is not a lot of resizing (copy) 1 to create the array
and 1 Resize (copy) when done reading the row Offsetts

Im still new to c# so comments on the code are welcome also...
reply and i''ll paste the code here
MJ
"Lee Crabtree" <lc*******@goisi.comwrote in message
news:Ok**************@TK2MSFTNGP02.phx.gbl...

框架中是否有一个类允许我以无缓冲的方式从

中的文件中读取文本?也就是说,我希望能够以与StreamReader.ReadLine()相同的方式读取

中的行,但我还需要能够准确地确定
获取该行文件中的位置。由于StreamReader

和FileStream都是缓冲数据,因此你不能将BaseStream.Position

等同于你从流中读取的数据。


Lee Crabtree
Is there a class in the framework that allows me read text from a file in
an unbuffered manner? That is, I''d like to be able to read lines in the
same manner as StreamReader.ReadLine(), but I also need to be able to
accurately get the position in the file of that line. Since StreamReader
and FileStream both buffer data, you can''t equate the BaseStream.Position
with the data you''re reading from the stream.

Lee Crabtree



是的,我想看看你是如何处理的。可能是有教育意义的。


Lee Crabtree
Yeah, I''d like to see how you handled that. Could be educational.

Lee Crabtree


这篇关于无缓冲的文件IO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆