reading text files

Hi,

What would be the fastest way to read a text file of size >20MB ?
I need to read that log file and then I need to search for a particular string in it. The log file writes each entry in one line. So first I would do ReadLine() to read all the lines, then for each line I would do a .split() and then from resulting array I would read a value at a certain index of the array. Now if you are working with files of that big size its gonna take a long time to do all this and just to complicate things a little bit, I need to read the log files at regular intervals again and again and I need not to read the portion of the file that I have read before and each time start from the position where I left before.

How can I do all this ? specially not to read the portion of file read before.

Thanks,

[812 byte] By [bilalso] at [2007-12-16]
# 1
If you need to re-read the log file. Just keep track of the last line that you read.

Or possibly look at moving the log file to a database and use timestamps to keep track of what you read.

Not sure what you are looking for in each line. You might want to use IndexOf( ) to find the string rather than splitting the entire line.

DanVallejo at 2007-9-9 > top of Msdn Tech,.NET Development,.NET Base Class Library...

.NET Development

Site Classified