Copies bytes from the current buffered stream to an array.
[Visual Basic] Overrides Public Function Read( _ ByVal array() As Byte, _ ByVal offset As Integer, _ ByVal count As Integer _ ) As Integer [C#] public override int Read( byte[] array, int offset, int count ); [C++] public: override int Read( unsigned char* array[], int offset, int count ); [JScript] public override function Read( array : Byte[], offset : int, count : int ) : int;
The total number of bytes read into array. This may be less than the number of bytes requested if that many bytes aren't currently available, or zero if the end of the stream has been reached before any data can be read.
Exception Type | Condition |
---|---|
ArgumentException | Length of array minus offset is less than count. |
ArgumentNullException | array is null. |
ArgumentOutOfRangeException | offset or count is less than zero. |
IOException | The stream is not open or is null. |
NotSupportedException | The stream does not support reading. |
Note that BufferedStream.Read(byte[], int, int) and BufferedStream.Write(byte[], int, int) read and write the number of bytes specified by the count parameter, while StreamReader.Read(char[], int, int) and StreamReader.Write(char[], int, int) read and write the number of characters specified by the count parameter. Use the BufferedStream methods only for reading and writing bytes.
The Read method will return zero only if the end of the stream is reached. In all other cases, Read always reads at least one byte from the stream before returning. If no data is available from the stream upon a call to Read, the method will block until at least one byte of data can be returned.
BufferedStream Class | BufferedStream Members | System.IO Namespace | BlockCopy | CanRead | Write