I can't understand why I'm getting this error. I'm trying to parse a tab seperated file. After 10 lines being read it throws the above error which is an ObjectDisposedException.
The above function is called through the following while loop:
I can't understand it, it's called and operates fine for the first 10 iterations and on the 11th throws and error. There is nothing special about that line in the log file.
VB.NET:
Public Function readNextLine(ByRef buffer As Single()) As Boolean
Dim i As Integer
Dim tempString As String()
If Not (fileNfo.Exists) Then
MsgBox("File does not exist, it has been moved or deleted")
readNextLine = False
ElseIf (fStream Is Nothing) Then
MsgBox("There was a problem reading the file, please try again")
readNextLine = False
ElseIf (fStreamReader Is Nothing) Then
MsgBox("There was a problem reading the file, please try again")
readNextLine = False
Else
tempString = Split(fStreamReader.ReadLine(), cDelim) 'Error thrown here
ReDim buffer(tempString.Length - 2)
For i = 0 To tempString.Length - 2
If (IsNumeric(tempString(i))) Then
buffer(i) = CSng(tempString(i))
Else
buffer(i) = 0
End If
Next
readNextLine = True
End If
End Function
The above function is called through the following while loop:
VB.NET:
Private Sub file_to_dataset(ByVal fileInfo As System.IO.FileInfo)
Dim singleRead As Single() = {0}
If Not (fileInfo.Exists) Then Exit Sub 'File does not exist
If (fileParser Is Nothing) Then
fileParser = New clsFileParser(fileInfo, vbTab)
End If
dsLogData.Clear()
While fileParser.peek() <> -1
If (fileParser.readNextLine(singleRead)) Then
If (singleRead.Length = dsLogData.Columns.Count) Then
dsLogData.Rows.Add(singleRead)
End If
End If
End While
End Sub
I can't understand it, it's called and operates fine for the first 10 iterations and on the 11th throws and error. There is nothing special about that line in the log file.