I have a text file which needs to be formatted. I need to find index of some of the lines. This is my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim filename As String = "C:\temp\Water Purge THM&VOC 061311_20110707_11.rqt"
Dim Lines As New List(Of String)(IO.File.ReadAllLines(filename))
Dim oneLine As String = String.Empty
Dim fileReader As New StreamReader(filename)
Do While fileReader.Peek() <> -1
For i As Integer = 0 To Lines.Count - 1
oneLine = fileReader.ReadLine
If oneLine.Length > 0 Then
Dim FindIndex As Integer = (Lines.FindIndex(AddressOf FindStr))
Response.Write("found " & FindIndex)
Shared Function FindStr(ByVal oneLine As String) As Boolean
If oneLine.Substring(0, 4) = "2001" Then
I receive error message:
Index and length must refer to a location within the string.
Parameter name: length
I assume that it is because there are empty lines but how can I resolve the problem?