Skip to main content

StorageProviderExtensions Class

Definition

Assembly:Avalonia.Base
Package:Avalonia

Group of public extensions for Avalonia.Platform.Storage.IStorageProvider class.

public class StorageProviderExtensions

Inheritance: object -> StorageProviderExtensions

Methods

NameDescription
TryGetFileFromPathAsyncAttempts to read file from the file-system by its path.
TryGetFolderFromPathAsyncAttempts to read folder from the file-system by its path.
TryGetLocalPathGets the local file system path of the item as a string.

TryGetFileFromPathAsync Method

Attempts to read file from the file-system by its path.

public System.Threading.Tasks.Task<Avalonia.Platform.Storage.IStorageFile> TryGetFileFromPathAsync(Avalonia.Platform.Storage.IStorageProvider provider, string filePath)

Parameters

provider Avalonia.Platform.Storage.IStorageProvider

filePath string

The path of the item to retrieve in Uri format.

Returns

System.Threading.Tasks.Task<Avalonia.Platform.Storage.IStorageFile>

File or null if it doesn't exist.

Remarks

Uri path is usually expected to be an absolute path with "file" scheme. But it can be an uri with "content" scheme on the Android. It also might ask user for the permission, and throw an exception if it was denied.

TryGetFolderFromPathAsync Method

Attempts to read folder from the file-system by its path.

public System.Threading.Tasks.Task<Avalonia.Platform.Storage.IStorageFolder> TryGetFolderFromPathAsync(Avalonia.Platform.Storage.IStorageProvider provider, string folderPath)

Parameters

provider Avalonia.Platform.Storage.IStorageProvider

folderPath string

The path of the folder to retrieve in Uri format.

Returns

System.Threading.Tasks.Task<Avalonia.Platform.Storage.IStorageFolder>

Folder or null if it doesn't exist.

Remarks

Uri path is usually expected to be an absolute path with "file" scheme. But it can be an uri with "content" scheme on the Android. It also might ask user for the permission, and throw an exception if it was denied.

TryGetLocalPath Method

Gets the local file system path of the item as a string.

public string TryGetLocalPath(Avalonia.Platform.Storage.IStorageItem item)

Parameters

item Avalonia.Platform.Storage.IStorageItem

Storage folder or file.

Returns

string

Full local path to the folder or file if possible, otherwise null.

Remarks

Android platform usually uses "content:" virtual file paths and Browser platform has isolated access without full paths, so on these platforms this method will return null.