更新:2007 年 11 月
如果在当前光标位置和文件结尾之间没有非空白、非注释的行,则返回 True。
' Usage
Dim value As Boolean = TextFieldParserObject.EndOfData
' Declaration
Public ReadOnly Property EndOfData As Boolean
返回值
Boolean.
备注
当从文件中读取数据时,可以使用此属性来确定所读取数据的结尾。
任务
下表列出了涉及 EndOfData 属性的任务的示例。
| 要执行的操作 | 请参见 | 
|---|---|
| 从分隔的文件读取 | |
| 从固定宽度的文件中读取 | 
示例
此示例通过 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
要求
命名空间:Microsoft.VisualBasic.FileIO
**程序集:**Visual Basic Runtime Library(位于 Microsoft.VisualBasic.dll 中)
权限
下面的权限是必需的:
| 权限 | 说明 | 
|---|---|
| 控制访问文件和文件夹的能力。关联的枚举:Unrestricted。 | |
| 描述应用于代码的安全权限集。关联的枚举:ControlEvidence。 |