CryptoStream.Read(Byte[], Int32, Int32) 方法

定义

从当前流读取字节序列,并将流中的位置向前移动读取的字节数。Reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

public:
 override int Read(cli::array <System::Byte> ^ buffer, int offset, int count);
public override int Read (byte[] buffer, int offset, int count);
override this.Read : byte[] * int * int -> int
Public Overrides Function Read (buffer As Byte(), offset As Integer, count As Integer) As Integer

参数

buffer
Byte[]

字节数组。An array of bytes. 从当前流中读取最多的 count 个字节,并将它们存储在 buffer 中。A maximum of count bytes are read from the current stream and stored in buffer.

offset
Int32

buffer 中的字节偏移量,从该偏移量开始存储从当前流中读取的数据。The byte offset in buffer at which to begin storing the data read from the current stream.

count
Int32

要从当前流中读取的最多字节数。The maximum number of bytes to be read from the current stream.

返回

读入缓冲区中的总字节数。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.

异常

与当前 CryptoStreamMode 对象关联的 CryptoStream 与基础流不匹配。The CryptoStreamMode associated with current CryptoStream object does not match the underlying stream. 例如,对只写的基础流使用 Read 时会引发此异常。For example, this exception is thrown when using Read with an underlying stream that is write only.

offset 参数小于零。The offset parameter is less than zero.

- 或 --or- count 参数小于零。The count parameter is less than zero.

count 参数和 offset 参数的和比缓冲区的长度长。The sum of the count and offset parameters is longer than the length of the buffer.

适用于

另请参阅