如何更快地阅读VB.NET文本文件 [英] How do I read a text file faster VB.NET

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

问题描述

所以我在这里有一行代码:

So i have a line of code here :

Dim scanbox As String
            scanbox = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\Database\TextFile1.dat").ToString



和一个包含600万行的巨大文件,而且readalltext需要很长时间。所以我的问题是有一种更快的方式,然后我的代码在几秒钟内读取它而不是20秒?



我尝试过:



我环顾四周,但它与我正在寻找的东西不同,我不确定我要做什么。


and its a huge file with like 6 million lines, And it takes ages to readalltext. So my question is there a faster way then my code to read it in seconds instead of like 20 secounds?

What I have tried:

I've looked around but its all differnt to what im looking for and im not sure what im going to do.

推荐答案

你真的需要在内存中同时拥有所有文件内容(我怀疑你这样做了吗?)

根据你的情况,可能有几种选择。例如,您的应用程序可以预处理文件(存储结果),然后仅处理文件更新(假设它是一种日志)。
Do you really need to have all the file content at once in memory (I doubt you do)?
Depending on your scenario there might be several alternatives. As an example your application could pre-process the file (storing the results) and then work just on file updates (assuming it is a kind of log).


这篇关于如何更快地阅读VB.NET文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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