StreamExtensions Class
Provides extension methods for Stream.
public static class StreamExtensionsMethods
| Name | Description |
|---|---|
| ReadToEnd(Stream) | Reads all remaining bytes from the stream. |
| ReadToEndAsync(Stream, CancellationToken) | Asynchronously reads all remaining bytes from the stream. |
| ToMemoryStreamAsync(Stream, CancellationToken) | Asynchronously copies the stream to a new MemoryStream and returns it positioned at the beginning. |
| TryReadAll(Stream, byte[], int, int) | Attempts to read all requested bytes from the stream into the buffer. |
| TryReadAll(Stream, Span<byte>) | Attempts to read all requested bytes from the stream into the buffer span. |
| TryReadAllAsync(Stream, byte[], int, int, CancellationToken) | Asynchronously attempts to read all requested bytes from the stream into the buffer. |
| TryReadAllAsync(Stream, Memory<byte>, CancellationToken) | Asynchronously attempts to read all requested bytes from the stream into the buffer memory. |
ReadToEnd(Stream)
StreamExtensions.csReadToEndAsync(Stream, CancellationToken)
StreamExtensions.csAsynchronously reads all remaining bytes from the stream.
net10.0
public static Task<byte[]> ReadToEndAsync(this Stream stream, CancellationToken cancellationToken = default)net11.0
public static Task<byte[]> ReadToEndAsync(this Stream stream, CancellationToken cancellationToken = default)ToMemoryStreamAsync(Stream, CancellationToken)
StreamExtensions.csAsynchronously copies the stream to a new MemoryStream and returns it positioned at the beginning.
net10.0
public static Task<MemoryStream> ToMemoryStreamAsync(this Stream stream, CancellationToken cancellationToken = default)net11.0
public static Task<MemoryStream> ToMemoryStreamAsync(this Stream stream, CancellationToken cancellationToken = default)TryReadAll overloads
TryReadAll(Stream, byte[], int, int)
StreamExtensions.csTryReadAll(Stream, Span<byte>)
StreamExtensions.csTryReadAllAsync overloads
TryReadAllAsync(Stream, byte[], int, int, CancellationToken)
StreamExtensions.csAsynchronously attempts to read all requested bytes from the stream into the buffer.
public static Task<int> TryReadAllAsync(this Stream stream, byte[] buffer, int offset, int count, CancellationToken cancellationToken = default)TryReadAllAsync(Stream, Memory<byte>, CancellationToken)
StreamExtensions.csAsynchronously attempts to read all requested bytes from the stream into the buffer memory.
net10.0
public static Task<int> TryReadAllAsync(this Stream stream, Memory<byte> buffer, CancellationToken cancellationToken = default)