
ReadToEnd Method | 605
The ‘My’
Reference
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
See Also
Close Method, CommentTokens Property, EndOfData Property, LineNumber Property,
PeekChars Method, ReadFields Method, ReadToEnd Method, TextFieldParser Object
ReadToEnd Method
Location
TextFieldParser.ReadToEnd
Syntax
Dim fileParser As FileIO.TextFieldParser
' ...later...
Dim result As String = fileParser.ReadToEnd( )
Description
The ReadToEnd method reads and returns the remaining text in a file being parsed
with the TextFieldParser object, starting from the current file position. The text
returned is not parsed into distinct fields and may include blank lines and comment
lines. If the file position is already at the end of file, this method returns an empty
string.
This method advances the current file position to the end of the file and sets the
parser’s LineNumber property to -
1.
Usage at a Glance
You must close the TextFieldParser object when finished with it. Use the object’s Close
method or create the object instance with the
Using keyword. See the TextFieldParser
Object entry in this chapter for an example.
Example
This code opens a tab-delimited file for scanning but looks for non-delimited data near
the end of the file.
Dim oneLine( ) As String
Dim commentary As String
Dim inputFile As FileIO.TextFieldParser = _
My.Computer.FileSystem.OpenTextFieldParser( ...