|
-
Apr 12th, 2006, 07:57 PM
#1
Thread Starter
Fanatic Member
[RESOLVED] [2005] Io.streamreader
I'm reading a text file through a streamreader. Does the streamreader have something like a "number of lines in file" property, or do I just have to loop until the eof? Thanks.
-
Apr 12th, 2006, 08:04 PM
#2
Re: [2005] Io.streamreader
VB Code:
Debug.Print(ioReader.ReadToEnd.Split(CChar(Environment.NewLine)).GetUpperBound(0).ToString)
-
Apr 12th, 2006, 08:12 PM
#3
Re: [2005] Io.streamreader
A StreamReader is a forward-only stream. This means it has no idea what data is available on the stream until it reads it, but once it has read it it cannot go back and read it again. Remix's code will give you the number of lines (or actually one less than the number of lines) but, as you see, it has to read the entire file to get that information. There is no way to, for instance, only read the file if it is greater than a certain length. You must read the whole file to determine that length.
-
Apr 12th, 2006, 08:12 PM
#4
Thread Starter
Fanatic Member
Re: [2005] Io.streamreader
Last edited by Nove; Apr 12th, 2006 at 08:41 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|