Method CreateFromFileAsync
CreateFromFileAsync(string, CancellationToken)
Creates a new Attachment instance asynchronously by loading content from the specified file path.
public static Task<Attachment> CreateFromFileAsync(string path, CancellationToken cancellationToken = default)
Parameters
pathstringThe file system path to the attachment file.
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
- FileNotFoundException
Thrown when the specified file does not exist.
- UnsupportedFileTypeException
Thrown when the file format is not supported.
- OperationCanceledException
Thrown when the operation is canceled.
- See Also