This documentation is archived and is not being maintained.

CryptoStream.Read Method

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

[Visual Basic]
Overrides Public Function Read( _
   <InteropServices.In(), _
   Out()> ByVal buffer() As Byte, _
   ByVal offset As Integer, _
   ByVal count As Integer _
) As Integer
[C#]
public override int Read(
   [
   In,
   Out
] byte[] buffer,
 int offset,
 int count
);
[C++]
public: int Read(
   [
   In,
   Out
] unsigned char buffer __gc[],
 int offset,
 int count
);
[JScript]
public override 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 can be less than the number of bytes requested if that many bytes are not currently available, or zero if the end of the stream has been reached.

Exceptions

Exception Type Condition
NotSupportedException The current stream is not readable.
ArgumentOutOfRangeException The offset parameter is less than zero.

-or-

The count parameter is less than zero.

ArgumentException Thesum of the count and offset parameters is longer than the length of the buffer.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

CryptoStream Class | CryptoStream Members | System.Security.Cryptography Namespace | Cryptographic Services

Show: