Udostępnij za pośrednictwem


TextFieldParser.ReadToEnd Method

Reads the remainder of the text file and returns it as a string.

' Usage
Dim value As String = TextFieldParserObject.ReadToEnd()
' Declaration
Public Function ReadToEnd() As String

Return Value

String.

Remarks

This is an advanced member; it does not show in IntelliSense unless you click the All tab.

If there is nothing more to read because the end of the file has been reached, Nothing is returned.

The ReadToEnd method does not ignore blank lines and comments.

Example

This example uses the ReadToEnd method to read the entire file ParserText.txt and write it to the file Testfile.txt.

Using FileReader As New _
Microsoft.VisualBasic.FileIO.TextFieldParser("C:\ParserText.txt")
    Dim allText As String = FileReader.ReadToEnd
    My.Computer.FileSystem.WriteAllText("C://testfile.txt", allText, True)
End Using

If Testfile.txt does not exist, it is created by the WriteAllText method.

Requirements

Namespace:Microsoft.VisualBasic.FileIO

Class:TextFieldParser

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Permissions

No permissions are required.

See Also

Concepts

Parsing Text Files with the TextFieldParser Object

Reference

TextFieldParser Object

TextFieldParser.ReadToEnd

TextFieldParser.ReadFields Method

TextFieldParser.ReadLine Method