TextFieldParser.ErrorLine Property


Returns the line that caused the most recent MalformedLineException exception.

 property System::String ^ ErrorLine { System::String ^ get(); };
public string ErrorLine { get; }
member this.ErrorLine : string
Public ReadOnly Property ErrorLine As String

Property Value

The line that caused the most recent MalformedLineException exception.


This example uses the ErrorLine property to display the line causing the current MalformedLineException exception.

Dim FileReader As Microsoft.VisualBasic.FileIO.TextFieldParser
FileReader = My.Computer.FileSystem.OpenTextFieldParser("C:\test.txt")
Dim currentRow As String()
While Not FileReader.EndOfData
        currentRow = FileReader.ReadFields
        For Each currentField As String In currentRow
                "C://testfile.txt", currentField, True)
    Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
        MsgBox("Line " & FileReader.ErrorLine & " is not valid.")
    End Try
End While


If no MalformedLineException exceptions have been thrown, an empty string is returned.

The ErrorLineNumber property can be used to display the number of the line that caused the exception.

The following table lists examples of tasks involving the ErrorLine property.

To See
Read from a delimited file How to: Read From Comma-Delimited Text Files
Read from a fixed-width file How to: Read From Fixed-width Text Files

Applies to

See also