Ive been looking up on google and I cant seem to get anything. I know how to read a text file but I want to just get the second line. How would this be done?
Ive been looking up on google and I cant seem to get anything. I know how to read a text file but I want to just get the second line. How would this be done?
You can do loop while reading line by line and stop the loop when you get in the second line
How would I check that its on the second line?
Check out the StreamReader.ReadLine Method. Call it once and do nothing with the results and the 2nd call will get you the 2nd line from the file.
This pattern in common to all great programmers I know: they're not experts in something as much as experts in becoming experts in something.
The best programming advice I ever got was to spend my entire career becoming educable. And I suggest you do the same.
You can't just get a specific line. To get line N you must then you have to read every line before that and, if you don't need them, just discard them.vb.net Code:
Private Function GetLineFromFile(filePath As String, lineNumber As Integer) As String Using reader As New IO.StreamReader(filePath) Dim line As String = Nothing For i = 1 To lineNumber line = reader.ReadLine() If line = Nothing Then 'No more lines Exit For End If Next Return line End Using End Function
2007-2013
Why is my data not saved to my database? | Communicating between multiple forms | MSDN Data Walkthroughs
MSDN "How Do I?" Videos: VB | C#
VBForums Database Development FAQ
My CodeBank Submissions: VB (*NEW* Match Two Game, *NEW* More Random Random Numbers) | C# (*NEW* Match Two Game, *NEW* More Random Random Numbers)
My Blog: Using Parameters in ADO.NET | Keyboard Events | Assemblies & Namespaces