LocationTextFieldParser.ReadToEnd SyntaxDim fileParser As FileIO.TextFieldParser ' ...later... Dim result As String = fileParser.ReadToEnd( ) DescriptionThe 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 GlanceYou 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. ExampleThis 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( _ "c:\temp\data.txt", vbTab) Do While Not inputFile.EndOfData ' ----- Check for the start of the commentary. If (inputFile.PeekChars(9) = "COMMENTS:") Then ' ----- Skip the first line. commentary = inputFile.ReadLine( ) commentary = inputFile.ReadToEnd( ) Else ' ----- OK to process this line. oneLine = inputFile.ReadFields( ) ' ----- Process data here... End If Loop inputFile.Close( ) Related Framework Entries
See AlsoClose Method, CommentTokens Property, EndOfData Property, LineNumber Property, PeekChars Method, ReadFields Method, ReadLine Method, TextFieldParser Object |