Прочетете на английски Редактиране

Споделяне чрез


BinaryData.FromStreamAsync Method

Definition

Overloads

FromStreamAsync(Stream, CancellationToken)

Creates a BinaryData instance from the specified stream. The stream is not disposed by this method.

FromStreamAsync(Stream, String, CancellationToken)

FromStreamAsync(Stream, CancellationToken)

Source:
BinaryData.cs
Source:
BinaryData.cs
Source:
BinaryData.cs

Creates a BinaryData instance from the specified stream. The stream is not disposed by this method.

C#
public static System.Threading.Tasks.Task<BinaryData> FromStreamAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellationToken = default);

Parameters

stream
Stream

The stream containing the data.

cancellationToken
CancellationToken

A token that may be used to cancel the operation.

Returns

A value representing all of the data remaining in stream.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This method stores in the task it returns all non-usage exceptions that the method's synchronous counterpart can throw. If an exception is stored into the returned task, that exception will be thrown when the task is awaited. Usage exceptions, such as ArgumentException, are still thrown synchronously. For the stored exceptions, see the exceptions thrown by FromStream(Stream).

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)

FromStreamAsync(Stream, String, CancellationToken)

Source:
BinaryData.cs
Source:
BinaryData.cs
Source:
BinaryData.cs
C#
public static System.Threading.Tasks.Task<BinaryData> FromStreamAsync(System.IO.Stream stream, string? mediaType, System.Threading.CancellationToken cancellationToken = default);

Parameters

stream
Stream
mediaType
String
cancellationToken
CancellationToken

Returns

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Applies to

.NET 10 (package-provided) и други версии
Продукт Версии
.NET 8 (package-provided), 9 (package-provided), 10 (package-provided)
.NET Standard 2.0 (package-provided)