public sealed class NativePickerBackend : IPickerBackend, IFileDialogs Converts acquired native selections to safe, single-use file leases.
Constructors
NativePickerBackend
public NativePickerBackend(INativeWindowOwner owner, INativeFilePicker picker) Converts acquired native selections to safe, single-use file leases.
Properties
IsAvailable
public bool IsAvailable { get; } Whether the provider can currently show dialogs.
Documentation from IPickerBackend.IsAvailable.
SupportsAtomicReplace
public bool SupportsAtomicReplace { get; } Whether selected save destinations can be staged and atomically replaced.
Documentation from IPickerBackend.SupportsAtomicReplace.
SupportsDirectorySelection
public bool SupportsDirectorySelection { get; } Whether this backend implements local directory selection.
Remarks
This reports the backend's IFileDialogs.OpenDirectoryAsync implementation before a call; it does not select behavior. Return true exactly when the backend implements that method, and keep the inherited default (false) only when it relies on the default method, which reports PlatformUnavailableReason.BackendUnavailable. PresentationFiles reports the platform.directories.open capability from this value and always calls the backend's method; it throws InvalidOperationException when a backend reporting false returns anything other than Unavailable, after releasing any selected access.
Documentation from IPickerBackend.SupportsDirectorySelection.
SupportsDocumentAccess
public bool SupportsDocumentAccess { get; } Whether this backend implements IFileDialogs.OpenDocumentAsync and IFileDialogs.SaveDocumentAsync.
Remarks
PresentationFiles reports the platform.files.openDocument capability from this value and returns PlatformUnavailableReason.BackendUnavailable from both methods without calling a backend that reports false.
Documentation from IPickerBackend.SupportsDocumentAccess.
SupportsMultipleDirectorySelection
public bool SupportsMultipleDirectorySelection { get; } Whether this backend implements IFileDialogs.OpenDirectoriesAsync.
Remarks
PresentationFiles reports the platform.directories.openMultiple capability from this value and returns PlatformUnavailableReason.BackendUnavailable from OpenDirectoriesAsync without calling a backend that reports false.
Documentation from IPickerBackend.SupportsMultipleDirectorySelection.
SupportsMultipleSelection
public bool SupportsMultipleSelection { get; } Whether this backend implements IFileDialogs.OpenFilesAsync.
Remarks
PresentationFiles reports the platform.files.openMultiple capability from this value and returns PlatformUnavailableReason.BackendUnavailable from OpenFilesAsync without calling a backend that reports false.
Documentation from IPickerBackend.SupportsMultipleSelection.
Methods
OpenDirectoriesAsync
public ValueTask<PickerResult<IDirectoryLeaseList>> OpenDirectoriesAsync(OpenDirectoryOptions options, CancellationToken cancellationToken = default) Selects one or more directories and acquires access to each for C# filesystem operations.
Remarks
Each lease keeps its directory's access, as IFileDialogs.OpenDirectoryAsync does, until it, the list or the presentation is disposed. The default implementation returns Unavailable with PlatformUnavailableReason.BackendUnavailable; a provider that implements multiple directory selection overrides it and reports the platform.directories.openMultiple capability.
Documentation from IFileDialogs.OpenDirectoriesAsync.
OpenDirectoryAsync
public ValueTask<PickerResult<IDirectoryLease>> OpenDirectoryAsync(OpenDirectoryOptions options, CancellationToken cancellationToken = default) Selects directory access for C# filesystem operations. A provider without directory selection reports unavailable.
Remarks
The default implementation returns Unavailable with PlatformUnavailableReason.BackendUnavailable. A provider that implements directory selection overrides this method and also reports that support through its capability declaration, such as IPickerBackend.SupportsDirectorySelection in Runic.Platform.Runtime.
Documentation from IFileDialogs.OpenDirectoryAsync.
OpenDocumentAsync
public ValueTask<PickerResult<IDocumentFileLease>> OpenDocumentAsync(OpenFileOptions options, CancellationToken cancellationToken = default) Selects an existing document for reading and saving back to it.
Remarks
Unlike IFileDialogs.OpenFileAsync, which opens the file once for reading, the lease reads the document again on each IDocumentFileLease.OpenReadAsync and writes it through ISaveFileLease.BeginWriteAsync. Whether those writes can replace the file is reported by the platform.files.save capability; a read-only grant reports PlatformUnavailableReason.AtomicReplaceUnavailable per write. The default implementation returns Unavailable with PlatformUnavailableReason.BackendUnavailable; a provider that implements it overrides it and reports the platform.files.openDocument capability.
Documentation from IFileDialogs.OpenDocumentAsync.
OpenFileAsync
public ValueTask<PickerResult<IReadFileLease>> OpenFileAsync(OpenFileOptions options, CancellationToken cancellationToken = default) Selects and acquires a single-use read lease.
Documentation from IFileDialogs.OpenFileAsync.
OpenFilesAsync
public ValueTask<PickerResult<IReadFileLeaseList>> OpenFilesAsync(OpenFileOptions options, CancellationToken cancellationToken = default) Selects one or more files and acquires a single-use read lease for each.
Remarks
The selection is all or nothing: if any selected file cannot be opened, every acquired lease is released and the result is Failed. Each lease holds an open file until it or the list is disposed. The default implementation returns Unavailable with PlatformUnavailableReason.BackendUnavailable; a provider that implements multiple selection overrides it and reports the platform.files.openMultiple capability.
Documentation from IFileDialogs.OpenFilesAsync.
SaveDocumentAsync
public ValueTask<PickerResult<IDocumentFileLease>> SaveDocumentAsync(SaveFileOptions options, CancellationToken cancellationToken = default) Selects a save destination, as IFileDialogs.SaveFileAsync does, as a document the application can read back and save again, such as for Save As.
Exceptions
ArgumentExceptionThe suggested name is empty or a path.
Remarks
The document does not exist until the first committed write: until then IDocumentFileLease.OpenReadAsync reports PlatformFailureCode.NotFound. The default implementation returns Unavailable with PlatformUnavailableReason.BackendUnavailable; a provider that implements it overrides it and reports the platform.files.openDocument capability.
Documentation from IFileDialogs.SaveDocumentAsync.
SaveFileAsync
public ValueTask<PickerResult<ISaveFileLease>> SaveFileAsync(SaveFileOptions options, CancellationToken cancellationToken = default) Selects and acquires a save destination.
Documentation from IFileDialogs.SaveFileAsync.