The Eng
The Eng

Reputation: 39

Loading big text files

I have to load a textfile into my software, which can be really big (at least 1.5 GB), because I need to read the last line of this file to enumerate some elements with the next part of the script. The needed time can be very long but, sometimes, it is not possible to read the file because of the following error:

System.OutOfMemoryException: 'Array dimensions exceeded supported range.'

Is there a way to solve this issue? Or maybe a different - and better - path that I can follow to do what I need?

EDIT I: Here follows more details:

Upvotes: 0

Views: 160

Answers (1)

Mary
Mary

Reputation: 15091

If you only need the last line of the file...

Dim LastLine = File.ReadLines("file.txt").Last()

Upvotes: 1

Related Questions