PDA

Click to See Complete Forum and Search --> : [2.0] quick question 'bout streamreader


Fromethius
Oct 15th, 2006, 03:34 PM
how do i read the last line of a document and put it into an array?

double lastLine = code for reading last line;
myArray.SetValue(lastLine, 0);

something like that?.. yea.. quick question. thanks

jmcilhinney
Oct 15th, 2006, 06:00 PM
To read the last line of a file using a StreamReader you must first read every other line because a StreamReader is forward-only. There is no way to know how many lines it contins without reading them. The StreamReader's Peek method returns -1 when there is no data remaining, so you can just read a line into a variable in a loop until Peek returns -1. Then the value in the variable is the last line.

Fromethius
Oct 15th, 2006, 07:05 PM
thank you so much!!!!!! it works now!!! *rates post*

Edit: I must go around and spread other rep first? What if jmc is the only one who helps me VBForums, huh?! huh?!!?!

lol.. sorry jmc =/

jmcilhinney
Oct 15th, 2006, 07:11 PM
I don't do it for the rep. I do it for the money that you send me completely voluntarily. ;)

Fromethius
Oct 15th, 2006, 07:24 PM
hehe.. right.... ;)