TextFieldParser.EndOfData Propiedad

Definición

Devuelve True si entre la actual posición del cursor y el final del archivo no hay líneas que no estén en blanco ni líneas que no sean comentarios.

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

Valor de propiedad

Es True si no quedan más datos para leer; de lo contrario, es False.

Ejemplos

En este ejemplo se usa la EndofData propiedad para recorrer en bucle todos los campos del archivo con 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

Comentarios

Esta propiedad se puede usar al leer archivos para determinar el final de los datos que se van a leer.

En la tabla siguiente se enumeran ejemplos de tareas relacionadas con la EndOfData propiedad .

En Vea
Lectura desde un archivo delimitado Procedimiento para leer archivos de texto delimitado por comas
Lectura desde un archivo de ancho fijo Procedimiento para leer archivos de texto de ancho fijo

Se aplica a

Consulte también