Free mag vol1 | Page 827

CHAPTER 20  FILE I/O AND OBJECT SERIALIZATION Figure 20-3. The contents of your *.txt file Reading from a Text File Next, you will learn to read data from a file programmatically by using the corresponding StreamReader type. Recall that this class derives from the abstract TextReader, which offers the functionality described in Table 20-9. Table 20-9. TextReader Core Members Member Meaning in Life Peek() Returns the next available character without actually changing the position of the reader. A value of -1 indicates you are at the end of the stream. Read() Reads data from an input stream. ReadBlock() Reads a specified maximum number of characters from the current stream and writes the data to a buffer, beginning at a specified index. ReadLine() Reads a line of characters from the current stream and returns the data as a string (a nu