WinRT_SafeStorage 1.0.2

dotnet add package WinRT_SafeStorage --version 1.0.2
NuGet\Install-Package WinRT_SafeStorage -Version 1.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="WinRT_SafeStorage" Version="1.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add WinRT_SafeStorage --version 1.0.2
#r "nuget: WinRT_SafeStorage, 1.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install WinRT_SafeStorage as a Cake Addin
#addin nuget:?package=WinRT_SafeStorage&version=1.0.2

// Install WinRT_SafeStorage as a Cake Tool
#tool nuget:?package=WinRT_SafeStorage&version=1.0.2

WinRT Safe Storage

  • Enough of InvalidOperationException, COMException or just undocumented exceptions?
  • Try Catch each storage method makes your code heavier?
  • You want to go back to Win32 because it was easier?
  • But you had to finish this one UWP project?

Well WinRT Safe Storage is here for that!
It might not be that clean, but at least every WinRT storage call isn't going to crash your app, and error handling is much easier.

Examples

Try

await SafeStorageFolder.TryGetFolderFromPathAsync(UrlBar.Text)
    .OnSuccess(async (folder) =>
        await ShowFolder(folder) )
    .OnError((exception) =>
        WarningMessage.Text = exception.Message );

or

var getFolderOperation = await SafeStorageFolder.TryGetFolderFromPathAsync(UrlBar.Text);

if (getFolderOperation.IsSuccess)
    await ShowFolder(getFolderOperation.Value);
else
    WarningMessage.Text = getFolderOperation.Exception.Message;

Try with return

var getParentOperation = await CurrentFolder.TryGetParentAsync();

if (getParentOperation.Value != null)
    await GoToAsync(getParentOperation.Value);

return getParentOperation.Value != null; // Is successful ?

Single convertion

await Launcher.LaunchFileAsync(safeFile.UnsafeFile);

Multi convertion

var safeFolders = new List<SafeStorageFolder>();

safeFolders.AddRange(StorageConverter.ToSafe(unsafeFolders));
Product Compatible and additional computed target framework versions.
Universal Windows Platform uap10.0.16299 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • UAP 10.0.16299

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.2 411 6/24/2022
1.0.1 378 6/21/2022