TextFieldParser.ErrorLine 속성

업데이트: 2007년 11월

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

' Usage
Dim value As String = TextFieldParserObject.ErrorLine
' Declaration
Public ReadOnly Property ErrorLine As String

반환 값

String.

설명

MalformedLineException 예외가 throw되지 않은 경우 빈 문자열이 반환됩니다.

TextFieldParser.ErrorLineNumber 속성을 사용하여 예외를 발생시킨 줄 번호를 표시할 수 있습니다.

작업

다음 표에서는 ErrorLine 속성과 관련된 작업의 예를 보여 줍니다.

작업

참조

쉼표로 구분한 파일에서 읽기

방법: Visual Basic에서 쉼표로 구분된 텍스트 파일 읽기

고정 폭 파일에서 읽기

방법: Visual Basic에서 고정 너비 텍스트 파일 읽기

예제

다음 예제에서는 ErrorLine 속성을 사용하여 현재 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.ErrorLine & " is not valid.")
    End Try
End While

요구 사항

네임스페이스:Microsoft.VisualBasic.FileIO

클래스:TextFieldParser

어셈블리: Visual Basic 런타임 라이브러리(Microsoft.VisualBasic.dll)

권한

사용 권한이 필요하지 않습니다.

참고 항목

작업

방법: Visual Basic에서 여러 형식의 텍스트 파일 읽기

방법: Visual Basic에서 고정 너비 텍스트 파일 읽기

방법: Visual Basic에서 쉼표로 구분된 텍스트 파일 읽기

방법: Visual Basic에서 Try...Catch 블록을 사용하여 코드 테스트

개념

TextFieldParser 개체를 사용하여 텍스트 파일 구문 분석

참조

TextFieldParser 개체

TextFieldParser.ErrorLine