Skip to content

Method WriteFileAsync ​

Namespace: Belay.Core
Assembly: Belay.Core.dll

WriteFileAsync(string, byte[], CancellationToken) ​

Writes data to a file on the device using adaptive chunked transfer. Automatically optimizes chunk size based on device communication performance. Based on official mpremote fs_writefile implementation with base64 encoding.

csharp
public Task WriteFileAsync(string remotePath, byte[] data, CancellationToken cancellationToken = default)

Parameters ​

remotePath string

Remote file path on device.

data byte[]

Data to write.

cancellationToken CancellationToken

Cancellation token.

Returns ​

Task

Exceptions ​

ArgumentException

Thrown when remotePath is null, empty, or contains invalid characters.

ArgumentNullException

Thrown when data is null.

DeviceException

Thrown when device communication fails or file operation fails.

OperationCanceledException

Thrown when the operation is canceled.

Released under the Apache License 2.0.