流阅读 [英] Stream Reading

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

问题描述

你好

我试图用C#中的BinaryStream读取一个大的二进制文件(大约50 MB).因此,由于Read()方法需要一些时间,因此在一条指令中读取所有数据.

您知道我可以用来更快地读取数据的任何方法吗?也许我如何使用差异线程同时从文件的不同部分读取数据?

谢谢

Hello

I am trying to read a big binary file (around 50 MB) with a BinaryStream in C#.So, reading all the data in a single instruction, as Read() method takes some time.

Do you know any method that I can use to read the data faster ?Maybe, how can I read it from different sections of the file in the same time using differet threads ?

Thank you

推荐答案

使用不同的线程会很疯狂.您正在读取文件,您的硬盘将神奇地读取不同的扇区而不会受到任何惩罚?我确实相信可以打开文件并按块读取它.但是您不会更快地获取数据,添加更多代码会使速度变慢,但是数量很少,而且您可以更快地访问初始数据.如果您需要所有数据来使用它,那么最好的选择就是它,它受HDD速度的限制,并且您无法在代码中进行更改.
Using different threads would be insane. You''re reading a file, you thnk your hard drive will magically read different sectors without some penalty ? I do believe it''s possible to open a file and read it in chunks, however. But you won''t get your data any faster, adding more code will slow it down, but only a miniscule amount, and you can access your initial data faster. If you need all the data to use it, then what you have is your best option, it''s limited by the speed of the HDD and you can''t change that in code.


这篇关于流阅读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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