Reads a specified maximum of characters from the current stream into a buffer, beginning at the specified index.
The number of characters that have been read, or 0 if at the end of the stream and no data was read. The number will be less than or equal to the count parameter, depending on whether the data is available within the stream.
Type Reason ArgumentException buffer .Length - index < count . ArgumentNullException buffer is null. ArgumentOutOfRangeException index or count is negative. System.IO.IOException An I/O error occurred.
-or-
The current stream is closed.
This method overrides TextReader.Read.
This method returns an integer so that it can return 0 if the end of the stream has been reached.
When using the StreamReader.Read(Char[], int, int) method, it is more efficient to use a buffer that is the same size as the internal buffer of the stream, where the internal buffer is set to your desired block size, and to always read less than the block size. If the size of the internal buffer was unspecified when the stream was constructed, its default size is 4 kilobytes (4096 bytes). If you manipulate the position of the underlying stream after reading data into the buffer, the position of the underlying stream might not match the position of the internal buffer. To reset the internal buffer, call the StreamReader.DiscardBufferedData method; however, this method slows performance and should be called only when absolutely necessary.
This method returns after either the number of characters specified by the count parameter are read, or the end of the file is reached. TextReader.ReadBlock(Char[], int, int) is a blocking version of erload:System.IO.StreamReader.Read.
For a list of common I/O tasks, see Common I/O Tasks.