StreamUtility.ReadExactlyAsync method (1 of 2)

Reads exactly count bytes from stream.

public static Task<byte[]> ReadExactlyAsync(this Stream stream, int count, 
    CancellationToken cancellationToken = default)
parameter description
stream The stream to read from.
count The count of bytes to read.
cancellationToken The cancellation token.

Return Value

A new byte array containing the data read from the stream.

See Also


StreamUtility.ReadExactlyAsync method (2 of 2)

Reads exactly count bytes from stream into buffer, starting at the byte given by offset.

public static Task ReadExactlyAsync(this Stream stream, byte[] buffer, int offset, int count, 
    CancellationToken cancellationToken = default)
parameter description
stream The stream to read from.
buffer The buffer to read data into.
offset The offset within the buffer at which data is first written.
count The count of bytes to read.
cancellationToken The cancellation token.

See Also