TextFieldParser.EndOfData プロパティ
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
現在のカーソル位置とファイルの末尾の間に空白以外のコメント行がない場合は、 True を返します。
public:
property bool EndOfData { bool get(); };
public bool EndOfData { get; }
member this.EndOfData : bool
Public ReadOnly Property EndOfData As Boolean
プロパティ値
True 読み取るデータがそれ以上ない場合。それ以外の場合は False。
例
この例では、EndofData プロパティを使用して、ファイル内のすべてのフィールドをTextFieldReaderFileReaderループ処理します。
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 テキスト ファイルから読み取る |
| 固定幅ファイルから読み取る | 方法: 固定幅テキスト ファイルから読み取る |