Skip to main content

IStorageProvider Interface

Definition​

Assembly:Avalonia.Base
Package:Avalonia
public interface IStorageProvider

Methods​

NameDescription
OpenFileBookmarkAsyncOpen Avalonia.Platform.Storage.IStorageBookmarkFile from the bookmark ID.
OpenFilePickerAsyncOpens the file picker dialog.
OpenFilePickerWithResultAsyncOpens the file picker dialog and returns additional information about the result.
OpenFolderBookmarkAsyncOpen Avalonia.Platform.Storage.IStorageBookmarkFolder from the bookmark ID.
OpenFolderPickerAsyncOpens the folder picker dialog.
SaveFilePickerAsyncOpens the save file picker dialog.
SaveFilePickerWithResultAsyncOpens the save file picker dialog and returns additional information about the result.
TryGetFileFromPathAsyncAttempts to read file from the file-system by its path.
TryGetFolderFromPathAsyncAttempts to read folder from the file-system by its path.
TryGetWellKnownFolderAsyncAttempts to read folder from the file-system by its path

OpenFileBookmarkAsync Method​

Open Avalonia.Platform.Storage.IStorageBookmarkFile from the bookmark ID.

public System.Threading.Tasks.Task<Avalonia.Platform.Storage.IStorageBookmarkFile> OpenFileBookmarkAsync(string bookmark)

Parameters​

bookmark string

Bookmark ID.

Returns​

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

Bookmarked file or null if OS denied request.

OpenFilePickerAsync Method​

Opens the file picker dialog.

public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Avalonia.Platform.Storage.IStorageFile>> OpenFilePickerAsync(Avalonia.Platform.Storage.FilePickerOpenOptions options)

Parameters​

options Avalonia.Platform.Storage.FilePickerOpenOptions

Returns​

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Avalonia.Platform.Storage.IStorageFile>>

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

OpenFilePickerWithResultAsync Method​

Opens the file picker dialog and returns additional information about the result.

public System.Threading.Tasks.Task<Avalonia.Platform.Storage.OpenFilePickerResult> OpenFilePickerWithResultAsync(Avalonia.Platform.Storage.FilePickerOpenOptions options)

Parameters​

options Avalonia.Platform.Storage.FilePickerOpenOptions

Returns​

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

Avalonia.Platform.Storage.OpenFilePickerResult with selected files and additional dialog information such as selected file type.

OpenFolderBookmarkAsync Method​

Open Avalonia.Platform.Storage.IStorageBookmarkFolder from the bookmark ID.

public System.Threading.Tasks.Task<Avalonia.Platform.Storage.IStorageBookmarkFolder> OpenFolderBookmarkAsync(string bookmark)

Parameters​

bookmark string

Bookmark ID.

Returns​

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

Bookmarked folder or null if OS denied request.

OpenFolderPickerAsync Method​

Opens the folder picker dialog.

public System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Avalonia.Platform.Storage.IStorageFolder>> OpenFolderPickerAsync(Avalonia.Platform.Storage.FolderPickerOpenOptions options)

Parameters​

options Avalonia.Platform.Storage.FolderPickerOpenOptions

Returns​

System.Threading.Tasks.Task<System.Collections.Generic.IReadOnlyList<Avalonia.Platform.Storage.IStorageFolder>>

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

SaveFilePickerAsync Method​

Opens the save file picker dialog.

public System.Threading.Tasks.Task<Avalonia.Platform.Storage.IStorageFile> SaveFilePickerAsync(Avalonia.Platform.Storage.FilePickerSaveOptions options)

Parameters​

options Avalonia.Platform.Storage.FilePickerSaveOptions

Returns​

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

Saved Avalonia.Platform.Storage.IStorageFile or null if user canceled the dialog.

SaveFilePickerWithResultAsync Method​

Opens the save file picker dialog and returns additional information about the result.

public System.Threading.Tasks.Task<Avalonia.Platform.Storage.SaveFilePickerResult> SaveFilePickerWithResultAsync(Avalonia.Platform.Storage.FilePickerSaveOptions options)

Parameters​

options Avalonia.Platform.Storage.FilePickerSaveOptions

Returns​

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

Avalonia.Platform.Storage.SaveFilePickerResult with saved file and additional dialog information such as selected file type.

TryGetFileFromPathAsync Method​

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

public System.Threading.Tasks.Task<Avalonia.Platform.Storage.IStorageFile> TryGetFileFromPathAsync(Uri filePath)

Parameters​

filePath Uri

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

Parameters​

folderPath Uri

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.

TryGetWellKnownFolderAsync Method​

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

public System.Threading.Tasks.Task<Avalonia.Platform.Storage.IStorageFolder> TryGetWellKnownFolderAsync(Avalonia.Platform.Storage.WellKnownFolder wellKnownFolder)

Parameters​

wellKnownFolder Avalonia.Platform.Storage.WellKnownFolder

Well known folder identifier.

Returns​

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

Folder or null if it doesn't exist.

Properties​

NameDescription
CanOpenReturns true if it's possible to open the file picker on the current platform.
CanPickFolderReturns true if it's possible to open the folder picker on the current platform.
CanSaveReturns true if it's possible to open the save file picker on the current platform.

CanOpen Property​

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

public bool CanOpen { get; set; }

CanPickFolder Property​

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

public bool CanPickFolder { get; set; }

CanSave Property​

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

public bool CanSave { get; set; }