![]() ![]() | ||
You can use the StreamReader class to read text data from files; here's the hierarchy of this class:
Object MarshalByRefObject TextReader StreamReader
You can find the more notable public properties of the StreamReader class in Table 13.14 and the more notable methods of this class in Table 13.15.
Property |
Means |
---|---|
BaseStream |
Holds the underlying stream, giving you access to that stream's properties and methods. |
CurrentEncoding |
Gets the character encoding for the stream reader. |
Method |
Means |
---|---|
Close |
Closes the stream reader. |
DiscardBufferedData |
Discards the data in the buffer. |
Peek |
Looks ahead and returns the next available character (but does not actually read it as Read would, so does not advance the read/write position). Returns -1 if there is no more data waiting to be read. |
Read |
Reads the next character or characters. |
ReadLine |
Reads a line of text from the stream, returning that data as a string. |
ReadToEnd |
Reads from the current position to the end of the stream. |
![]() ![]() | ||