FileExt.Write Method (String, Stream, CancellationToken)

Asynchronously writes the content of an sourceStream to a file at path.

Namespace: UltimateXR.Extensions.System.IO
Assembly: UltimateXR (in UltimateXR.dll) Version: 0.0.0.0

Syntax

C#

public static Task Write(
	string path,
	Stream sourceStream,
	CancellationToken ct = default
)

Parameters

 

path
Type: System.String
File full path to be opened for writing
sourceStream
Type: System.IO.Stream
Stream to be written into a file.
ct (Optional)
Type: System.Threading.CancellationToken
Optional cancellation token, to cancel the asynchronous operation

Return Value

Type: Task
An awaitable writing Task

Exceptions

ExceptionCondition
IOExceptionAn I/O error occurred while creating the file.
ArgumentExceptionpath is a zero-length string, contains only white space, or contains one or more invalid characters. You can query for invalid characters by using the GetInvalidPathChars() method.
PathTooLongExceptionThe path parameter is longer than the system-defined maximum length.
NotSupportedExceptionsourceStream does not support reading, or the destination stream does not support writing.
UnauthorizedAccessExceptionThe caller does not have the required permission.
OperationCanceledExceptionTask canceled using ct

See Also

Reference

FileExt Class
Write Overload
UltimateXR.Extensions.System.IO Namespace