StreamUtility.ReadBlockAsync method

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

public static Task<int> ReadBlockAsync(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.

Remarks

Unlike Stream.ReadAsync, this method will not return fewer bytes than requested unless the end of the stream is reached.

See Also