Read text file bottom up

  • Thread starter Thread starter Lam
  • Start date Start date
L

Lam

Hi

the default readline method in StreamReader read the text from the top to
bottom
how can I read a text file from the bottom to the top?
Thanks
 
Hi Lam,
you can use the ReadBlock method of StreamReader to read in a block of
data from a specified starting position

ReadBlock(char[], intIndex, intCount);

the char[] is where the data will be read to, intIndex is the starting
position of where to read and intCount is the max number of characters to
read.

You can have a loop which decrements intIndex from max to min which will
read the file backwards.


Hope that helps
Mark.
 
Thanks
one more question
How can I delete the line after I read in the line from the text file?

Mark R. Dawson said:
Hi Lam,
you can use the ReadBlock method of StreamReader to read in a block of
data from a specified starting position

ReadBlock(char[], intIndex, intCount);

the char[] is where the data will be read to, intIndex is the starting
position of where to read and intCount is the max number of characters to
read.

You can have a loop which decrements intIndex from max to min which will
read the file backwards.


Hope that helps
Mark.

Lam said:
Hi

the default readline method in StreamReader read the text from the top to
bottom
how can I read a text file from the bottom to the top?
Thanks
 
Back
Top