Click here to Skip to main content
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 0: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 OriginalGriff 6,189
1 Sergey Alexandrovich Kryukov 5,666
2 CPallini 4,810
3 George Jonsson 3,429
4 Gihan Liyanage 2,522

Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 21 Feb 2013
Copyright © CodeProject, 1999-2014
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