Skip to content

Method GetFileAsync

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

GetFileAsync(string, CancellationToken)

Reads a file from the device using adaptive chunked transfer. Automatically optimizes chunk size based on device communication performance. Based on official mpremote fs_readfile implementation with base64 encoding.

csharp
public Task<byte[]> GetFileAsync(string remotePath, CancellationToken cancellationToken = default)

Parameters

remotePath string

Remote file path on device.

cancellationToken CancellationToken

Cancellation token.

Returns

Task<byte[]>

The file contents.

Exceptions

ArgumentException

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

DeviceException

Thrown when device communication fails or file operation fails.

OperationCanceledException

Thrown when the operation is canceled.

Released under the Apache License 2.0.