public interface ISaveFileLease : IAsyncDisposable Owns an acquired save destination and its access grant.
Properties
DisplayName
string DisplayName { get; } A display filename, without a filesystem path.
Methods
BeginWriteAsync
ValueTask<PlatformResult<IFileWriteTransaction>> BeginWriteAsync(FileWritePolicy policy, CancellationToken cancellationToken = default) Begins one staged write, or reports unavailable before modifying the destination.
Remarks
A lease writes as often as the application saves: a new write can begin once the previous transaction's commit finished, whatever its outcome, or once that transaction was disposed. While a transaction is open the result is Failed with PlatformFailureCode.ResourceBusy. Disposing the lease disposes its open transaction.
A commit is NotCommitted with PlatformFailureCode.Conflict when the file no longer holds the content the application last saw: the selected file (or its absence), then the bytes of each committed write, and for an IDocumentFileLease the content of each IDocumentFileLease.OpenReadAsync. After CommitUnknown both the previous content and the staged bytes count as the application's own. A conflict therefore means another writer changed the file.
CreateBookmarkAsync
ValueTask<PlatformResult<ImmutableArray<byte>>> CreateBookmarkAsync(CancellationToken cancellationToken = default) Creates a bookmark of the file for IDesktopFileBookmarks.OpenDocumentAsync, such as for a recent-files list.
Remarks
The file must exist: a save destination that has not been written yet reports PlatformFailureCode.NotFound; create the bookmark after the first committed write. Store the bookmark again each time the document is reopened. Windows and Linux bookmarks are the file's path (in a Flatpak the document portal's path, which stays valid across launches); macOS bookmarks are NSURL bookmarks, security-scoped inside the App Sandbox. The default implementation returns Unavailable with PlatformUnavailableReason.BackendUnavailable, as leases of providers without bookmarks do.