Read a text file from bottom to top
Posted on 2011-02-16
I am using Visual Basic .net 2008 and need a little help.
I have several text files which contain some data. The data in text files is stored in a format like -
Now each file is over 2 MB in size. I need to read file from last line and check if I need to replace a record or not. If yes, then I can read the entire file and do the needful. If not then goto another file.
Now I do not want to read file from start to end. This will waste time specially if I figure that I do not need to modify the file. So how can I read from bottom to top so that as soon I come across the record I want to check I can determine if I need to modify the file or not. The possibility of finding required record lower down is very high.
I want this operation to run as fast as possible.
If you guys can give me a small code thru which I can read file from last record onwards to top and as fast as possible it will be great.