Method CreateFromStreamAsync
CreateFromStreamAsync(Stream, string, CancellationToken)
Creates a new Attachment instance asynchronously by reading content from the provided stream.
public static Task<Attachment> CreateFromStreamAsync(Stream data, string name, CancellationToken cancellationToken = default)
Parameters
dataStreamA readable Stream containing the attachment data. The stream is fully read; it is not disposed by this method.
namestringThe logical file name associated with this attachment.
cancellationTokenCancellationTokenA token to monitor for cancellation requests.
Returns
- Task<Attachment>
A task that represents the asynchronous operation. The task result contains the loaded Attachment.
Exceptions
- ArgumentNullException
Thrown when
dataornameisnull.- ArgumentException
Thrown when
datais not readable.- UnsupportedFileTypeException
Thrown if the stream data is not one of the supported formats.
- OperationCanceledException
Thrown when the operation is canceled.
- See Also