File.WriteAllBytesAsync(String, Byte[], CancellationToken) Method

Definition

Asynchronously creates a new file, writes the specified byte array to the file, and then closes the file. If the target file already exists, it is overwritten.

public static System.Threading.Tasks.Task WriteAllBytesAsync (string path, byte[] bytes, System.Threading.CancellationToken cancellationToken = default);
static member WriteAllBytesAsync : string * byte[] * System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Shared Function WriteAllBytesAsync (path As String, bytes As Byte(), Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

path
String

The file to write to.

bytes
Byte[]

The bytes to write to the file.

cancellationToken
CancellationToken

The token to monitor for cancellation requests. The default value is None.

Returns

Task

A task that represents the asynchronous write operation.

Applies to