TextFieldParser.ErrorLineNumber 속성

정의

최신 MalformedLineException 예외를 발생시킨 줄 번호를 반환합니다.

public:
 property long ErrorLineNumber { long get(); };
public long ErrorLineNumber { get; }
member this.ErrorLineNumber : int64
Public ReadOnly Property ErrorLineNumber As Long

속성 값

최신 MalformedLineException 예외를 발생시킨 줄의 번호입니다.

예제

이 예제에서는 사용 된 ErrorLineNumber 현재 예외를 발생 하는 줄의 위치를 표시 하는 MalformedLineException 속성입니다.

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

설명

MalformedLineException 예외가 throw되지 않은 경우 -1이 반환됩니다.

속성을 ErrorLine 사용하여 예외를 발생시킨 줄의 수를 표시할 수 있습니다. 줄 번호를 결정할 때 빈 줄과 주석은 무시되지 않습니다.

다음 표에서 관련 된 작업의 예제는 ErrorLineNumber 속성입니다.

대상 참조 항목
구분된 파일에서 읽기 방법: 쉼표로 구분된 텍스트 파일에서 읽기
고정 너비 파일에서 읽기 방법: 고정 너비 텍스트 파일에서 읽기

적용 대상

추가 정보