Table of Contents

Interface IStorageProvider

Namespace
Avalonia.Platform.Storage
Assembly
Avalonia.Base.dll
[NotClientImplementable]
public interface IStorageProvider
Extension Methods

Properties

CanOpen

Returns true if it's possible to open file picker on the current platform.

bool CanOpen { get; }

Property Value

bool

CanPickFolder

Returns true if it's possible to open folder picker on the current platform.

bool CanPickFolder { get; }

Property Value

bool

CanSave

Returns true if it's possible to open save file picker on the current platform.

bool CanSave { get; }

Property Value

bool

Methods

OpenFileBookmarkAsync(string)

Open IStorageBookmarkFile from the bookmark ID.

Task<IStorageBookmarkFile?> OpenFileBookmarkAsync(string bookmark)

Parameters

bookmark string

Bookmark ID.

Returns

Task<IStorageBookmarkFile>

Bookmarked file or null if OS denied request.

OpenFilePickerAsync(FilePickerOpenOptions)

Opens file picker dialog.

Task<IReadOnlyList<IStorageFile>> OpenFilePickerAsync(FilePickerOpenOptions options)

Parameters

options FilePickerOpenOptions

Returns

Task<IReadOnlyList<IStorageFile>>

Array of selected IStorageFile or empty collection if user canceled the dialog.

OpenFolderBookmarkAsync(string)

Open IStorageBookmarkFolder from the bookmark ID.

Task<IStorageBookmarkFolder?> OpenFolderBookmarkAsync(string bookmark)

Parameters

bookmark string

Bookmark ID.

Returns

Task<IStorageBookmarkFolder>

Bookmarked folder or null if OS denied request.

OpenFolderPickerAsync(FolderPickerOpenOptions)

Opens folder picker dialog.

Task<IReadOnlyList<IStorageFolder>> OpenFolderPickerAsync(FolderPickerOpenOptions options)

Parameters

options FolderPickerOpenOptions

Returns

Task<IReadOnlyList<IStorageFolder>>

Array of selected IStorageFolder or empty collection if user canceled the dialog.

SaveFilePickerAsync(FilePickerSaveOptions)

Opens save file picker dialog.

Task<IStorageFile?> SaveFilePickerAsync(FilePickerSaveOptions options)

Parameters

options FilePickerSaveOptions

Returns

Task<IStorageFile>

Saved IStorageFile or null if user canceled the dialog.

TryGetFileFromPathAsync(Uri)

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

Task<IStorageFile?> TryGetFileFromPathAsync(Uri filePath)

Parameters

filePath Uri

The path of the item to retrieve in Uri format.

Returns

Task<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(Uri)

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

Task<IStorageFolder?> TryGetFolderFromPathAsync(Uri folderPath)

Parameters

folderPath Uri

The path of the folder to retrieve in Uri format.

Returns

Task<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.

TryGetWellKnownFolderAsync(WellKnownFolder)

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

Task<IStorageFolder?> TryGetWellKnownFolderAsync(WellKnownFolder wellKnownFolder)

Parameters

wellKnownFolder WellKnownFolder

Well known folder identifier.

Returns

Task<IStorageFolder>

Folder or null if it doesn't exist.