Click here to Skip to main content
15,910,471 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So i have a line of code here :
Dim scanbox As String
            scanbox = My.Computer.FileSystem.ReadAllText(Application.StartupPath & "\Database\TextFile1.dat").ToString

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.
Posted
Updated 30-Oct-17 1:55am
Comments
Patrice T 30-Oct-17 7:49am    
Yes, use a computer 20 times faster.
F-ES Sitecore 30-Oct-17 8:01am    
Use something like a streamreader to read the file line by line. Google for examples.

1 solution

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).
 
Share this answer
 
Comments
CPallini 30-Oct-17 8:27am    
We need to know your full scenario. You gave us no hint about.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900