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.
<PackageVersion Include="WinRT_SafeStorage" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="WinRT_SafeStorage" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version 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.
#:package WinRT_SafeStorage@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=WinRT_SafeStorage&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=WinRT_SafeStorage&version=1.0.2
                    
Install as a Cake Tool

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 518 6/24/2022
1.0.1 466 6/21/2022