NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Stream.Read

Reads a sequence of bytes from the current stream and advances the current position within the stream by the number of bytes read.

[Visual Basic]
Overridable Public Function Read( _
   ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
) As Integer
[C#]
public virtual int Read(
   byte[] buffer,
   int offset,
   int count
);
[C++]
public: virtual int Read(
   unsigned char* buffer[],
   int offset,
   int count
);
[JScript]
public function Read(
   buffer : Byte[],
   offset : int,
   count : int
) : int;

Parameters

buffer
An array of bytes. A maximum of count bytes are read from the current stream and stored in buffer.
offset
The byte offset in buffer at which to begin storing the data read from the current stream.
count
The maximum number of bytes to be read from the current stream.

Return Value

The total number of bytes read into the buffer. 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.

Exceptions

Exception Type Condition
ArgumentException The result of offset subtracted from the buffer length is less than count.
ArgumentNullException buffer is null.
ArgumentOutOfRangeException offset or count is negative.
IOException An I/O error occurs.
NotSupportedException The stream does not support reading.

Remarks

The default implementation calls the asynchronous BeginRead method.

Implementations of this method read a maximum of count bytes from the current stream and store them in buffer

beginning at offset. The current position within the stream is advanced by the number of bytes read. However, if an exception occurs, the current position within the stream is unchanged. Implementations return the number of bytes read. The return value is zero only if the position is currently at the end of the stream. The implementation will block until at least one byte of data can be read, in the event that no data is available.

Use BinaryReader for reading primitive data types.

See Also

Stream Class | Stream Members | System.IO Namespace