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 파일 TextFieldReader의 모든 필드를 , FileReader로 반복합니다.

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 속성입니다.

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

적용 대상

추가 정보