Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
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
Comments
CHill60 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

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
 
Share this answer
 
v3

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900