Table of Contents

Class StreamExtensions

Namespace
NuvTools.Common.IO
Assembly
NuvTools.Common.dll

Provides extension methods for Stream objects.

public static class StreamExtensions
Inheritance
StreamExtensions
Inherited Members

Methods

ToByteList(Stream)

Converts the stream to a byte array synchronously.

public static byte[] ToByteList(this Stream value)

Parameters

value Stream

The stream to convert.

Returns

byte[]

A byte array containing the stream data.

Remarks

This method blocks synchronously. For asynchronous operations, use ToByteListAsync(Stream).

Exceptions

ArgumentNullException

Thrown when value is null.

ToByteListAsync(Stream)

Converts the stream to a byte array asynchronously.

public static Task<byte[]> ToByteListAsync(this Stream value)

Parameters

value Stream

The stream to convert.

Returns

Task<byte[]>

A task that represents the asynchronous operation. The task result contains a byte array with the stream data.

Remarks

This method reads the entire stream based on its Length property. The stream must support seeking and have a known length.

Exceptions

ArgumentNullException

Thrown when value is null.