Click here to Skip to main content
11,416,194 members (64,284 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: VB.NET
How to go back to previous line. For example currently i am reading the "line5:" in below case, agian i want to start the reading from "Line 2:". I have a question like how to go back to line 2.

Line 1: --- To do something----
Line 2: --- To do something----
Line 3: --- To do something----
Line 4: --- To do something----
Line 5: --- To do something----
Line 6: --- To do something----
Line 7: --- To do something----
Posted 21-Feb-13 1:27am
CHill60 at 21-Feb-13 6:36am
Your question needs clarifying. Try using the Improve question link to add some detail - for example post the code that you are using to read the file

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

If the files that will be read are not extra large files and are delimited by CRLF, you can use the ReadAllText method to read the entire file into a string and Strings.Split to create an array of Type String where each element of the array is a row of the file.
Dim arrFileContents() As String = Strings.Split( _
     My.Computer.FileSystem.ReadAllText( _
     "C:\bat\RestoreSQL.log"), vbCrLf)
Dim intMaxIndex as Integer = arrFileContents.GetUpperBound(0) ' The highest index of the array
Dim intFileRows as Integer = arrFileContents.GetUpperBound(0) + 1 ' The number of rows in the file

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 9,270
1 OriginalGriff 7,512
2 Maciej Los 3,710
3 Abhinav S 3,324
4 Peter Leow 3,084

Advertise | Privacy | Mobile
Web02 | 2.8.150427.4 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100