Streamreader to read specific line

Hi,
I am using visual studio 2005.How to use stream reader to read specific line number in a text?

Cheers
RIASAsked:
Who is Participating?
 
CluskittConnect With a Mentor Commented:
I just use a loop and dump the lines into a variable (an array if you want them all, a string if you just want the last one).

For a = 0 To 4
  sTemp = oRead.ReadLine
Next
0
 
Kiran SonawaneProject LeadCommented:
0
 
RIASAuthor Commented:
StreamReader.BaseStream Property?
0
 
CluskittCommented:
No. Just declare your streamreader and a string:

Dim oRead As New IO.StreamReader(FileName)
Dim sTemp As String

Then use the loop above to read the 5th line. Change the value to read whichever line you wish to read.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.