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 示します。

終了 解決方法については、
区切りファイルからの読み取り 方法: コンマ区切りのテキスト ファイルを読み取る
固定幅ファイルからの読み取り 方法: 固定幅のテキスト ファイルを読み取る

適用対象

こちらもご覧ください