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
public override int Read(
] byte[] buffer,
 int offset,
 int count
public: int Read(
] unsigned char buffer __gc[],
 int offset,
 int count
public override function Read(
   buffer : Byte[],
 offset : int,
 count : int
) : int;


An array of bytes. A maximum of count bytes are read from the current stream and stored in buffer.
The byte offset in buffer at which to begin storing the data read from the current stream.
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.


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


The count parameter is less than zero.

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


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