TextFieldParser.EndOfData 속성

정의

True 현재 커서 위치와 파일의 끝 사이에 공백이 아닌 주석이 아닌 줄이 없는 경우 반환합니다.

public:
 property bool EndOfData { bool get(); };
public bool EndOfData { get; }
member this.EndOfData : bool
Public ReadOnly Property EndOfData As Boolean

속성 값

True읽을 데이터가 더 이상 없으면 이고, 그렇지 않으면 . False

예제

이 예제에서는 속성을 사용하여 파일의 EndofData 모든 필드를 반복FileReader합니다TextFieldReader.

Dim StdFormat As Integer() = {5, 10, 11, -1}
Dim ErrorFormat As Integer() = {5, 5, -1}
Using FileReader As New  Microsoft.VisualBasic.FileIO.
    TextFieldParser("C:\testfile.txt")

    FileReader.TextFieldType = FileIO.FieldType.FixedWidth
    FileReader.FieldWidths = StdFormat
    Dim CurrentRow As String()
    While Not FileReader.EndOfData
        Try
            Dim RowType As String = FileReader.PeekChars(3)
            If String.Compare(RowType, "Err") = 0 Then
                ' If this line describes an error, the format of the row will be different.
                FileReader.SetFieldWidths(ErrorFormat)
                CurrentRow = FileReader.ReadFields
                FileReader.SetFieldWidths(StdFormat)
            Else
                ' Otherwise parse the fields normally
                CurrentRow = FileReader.ReadFields
                For Each newString As String In CurrentRow
                    My.Computer.FileSystem.WriteAllText("newFile.txt", newString, True)
                Next
            End If
        Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineException
            MsgBox("Line " & ex.Message & " is invalid.  Skipping")
        End Try
    End While
End Using

설명

파일에서 읽을 때 이 속성을 사용하여 읽는 데이터의 끝을 확인할 수 있습니다.

다음 표에서는 속성과 관련된 EndOfData 작업의 예를 나열합니다.

받는 사람 보십시오
구분된 파일에서 읽기 방법: Comma-Delimited 텍스트 파일에서 읽기
고정 너비 파일에서 읽기 방법: 고정 너비 텍스트 파일에서 읽기

적용 대상

추가 정보