IsolatedStorageFileStream.Read 方法

定义

重载

Read(Byte[], Int32, Int32)

将字节从当前缓冲的 IsolatedStorageFileStream 对象复制到字节数组。Copies bytes from the current buffered IsolatedStorageFileStream object to a byte array.

Read(Span<Byte>)

将字节从当前缓冲的 IsolatedStorageFileStream 对象复制到字节范围。Copies bytes from the current buffered IsolatedStorageFileStream object to a byte span.

Read(Byte[], Int32, Int32)

将字节从当前缓冲的 IsolatedStorageFileStream 对象复制到字节数组。Copies bytes from the current buffered IsolatedStorageFileStream object to a byte array.

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[]

要写入数据的缓冲区。The buffer to write the data into.

offset
Int32

缓冲区中开始写入的偏移量。The offset in the buffer at which to begin writing.

count
Int32

最多读取的字节数。The maximum number of bytes to read.

返回

Int32

读入 buffer 中的总字节数。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 is reached.

注解

buffer参数可以是类的实例 Buffer ,也可以是以下类型之一的数组: ByteSByte 、、 CharInt16 Int32 Int64 UInt16 UInt32 UInt64 Single Double 、、、、、或。The buffer parameter can be an instance of the Buffer class, or an array of one of the following types: Byte, SByte, Char, Int16, Int32, Int64, UInt16, UInt32, UInt64, Single, or Double.

如果读取操作成功,则流的当前位置将按读取的字节数提前。If the read operation is successful, the current position of the stream is advanced by the number of bytes read. 如果发生异常,则流的当前位置不变。If an exception occurs, the current position of the stream is unchanged.

Read方法将参数视为 buffer 字节块,而不考虑它的实际类型。The Read method treats the buffer parameter as a block of bytes, regardless of its actual type. 同样, offsetcount 参数始终以字节为单位指定。Likewise, the offset and count parameters are always specified in bytes. 对于 buffer 字节数组以外的参数,这意味着元素索引或元素数必须乘以元素大小(以字节为单位),以便为或形成正确的值 offset countFor buffer parameters other than byte arrays, this means that an element index or the number of elements must be multiplied by the element size in bytes to form a correct value for offset or count.

Read仅当到达流的末尾时,该方法才会返回零。The Read method will return zero only if the end of the stream is reached. 在所有其他情况下,在 Read 返回前始终从流中读取至少一个字节。In all other cases, Read always reads at least one byte from the stream before returning. 如果调用后对象中没有可用数据 IsolatedStorageFileStream Read ,则该方法将被阻止,直到至少有一个字节的数据可以返回。If no data is available from the IsolatedStorageFileStream object upon a call to Read, the method will block until at least one byte of data can be returned.

适用于

Read(Span<Byte>)

将字节从当前缓冲的 IsolatedStorageFileStream 对象复制到字节范围。Copies bytes from the current buffered IsolatedStorageFileStream object to a byte span.

public:
 override int Read(Span<System::Byte> buffer);
public override int Read (Span<byte> buffer);
override this.Read : Span<byte> -> int
Public Overrides Function Read (buffer As Span(Of Byte)) As Integer

参数

buffer
Span<Byte>

要写入数据的缓冲区。The buffer to write the data into.

返回

Int32

读入 buffer 中的总字节数。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 is reached.

适用于