Template10.Services.FileService 1.0.1

Handy File Service for WinRT. Part of Template 10, a Library of Helpers for UWP.

Install-Package Template10.Services.FileService -Version 1.0.1
dotnet add package Template10.Services.FileService --version 1.0.1
<PackageReference Include="Template10.Services.FileService" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Template10.Services.FileService --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Template10.Services.FileService, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Template10.Services.FileService as a Cake Addin
#addin nuget:?package=Template10.Services.FileService&version=1.0.1

// Install Template10.Services.FileService as a Cake Tool
#tool nuget:?package=Template10.Services.FileService&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

FileService

FileService simplifies the common ways of interacting with files by abstracting the storage types to Local, Roaming and Temporary. In doing so, the service takes care of correctly creating the appropriate paths. All storage strategies are within the app's own data directory. All calls that allow a storage strategy to be specified default to local storage.

// Deletes a file in the specified storage strategy. key is the path of the file in storage. This
// is safe to call even if the file doesn't exist already. Returns true if the deletion operation
// was successful (i.e. the file doesn't exist).
async Task<bool> DeleteFileAsync(string key, StorageStrategies location = StorageStrategies.Local)

// This checks for the existence of a file, either in the specified storage strategy or in the
// specified folder.
async Task<bool> FileExistsAsync(string key, StorageStrategies location = StorageStrategies.Local)
async Task<bool> FileExistsAsync(string key, StorageFolder folder)

// ReadFileAsync reads and deserializes a file into specified type T. T specifies the type into which
// to deserialize the file content while key is the path to the file within the specified storage strategy.
async Task<T> ReadFileAsync<T>(string key, StorageStrategies location = StorageStrategies.Local)

// WriteFileAsync serializes an object (of specified type T) and writes it to file in the specified storage
// strategy. Key specifies the path to the file within the storage strategy. You can also alter the behaviour
// if the code if the destination file already exists. The method returns a boolean to indicate whether or not
// the file exists.
async Task<bool> WriteFileAsync<T>(string key, T value, StorageStrategies location = StorageStrategies.Local,
            CreationCollisionOption option = CreationCollisionOption.ReplaceExisting)

FileService

FileService simplifies the common ways of interacting with files by abstracting the storage types to Local, Roaming and Temporary. In doing so, the service takes care of correctly creating the appropriate paths. All storage strategies are within the app's own data directory. All calls that allow a storage strategy to be specified default to local storage.

// Deletes a file in the specified storage strategy. key is the path of the file in storage. This
// is safe to call even if the file doesn't exist already. Returns true if the deletion operation
// was successful (i.e. the file doesn't exist).
async Task<bool> DeleteFileAsync(string key, StorageStrategies location = StorageStrategies.Local)

// This checks for the existence of a file, either in the specified storage strategy or in the
// specified folder.
async Task<bool> FileExistsAsync(string key, StorageStrategies location = StorageStrategies.Local)
async Task<bool> FileExistsAsync(string key, StorageFolder folder)

// ReadFileAsync reads and deserializes a file into specified type T. T specifies the type into which
// to deserialize the file content while key is the path to the file within the specified storage strategy.
async Task<T> ReadFileAsync<T>(string key, StorageStrategies location = StorageStrategies.Local)

// WriteFileAsync serializes an object (of specified type T) and writes it to file in the specified storage
// strategy. Key specifies the path to the file within the storage strategy. You can also alter the behaviour
// if the code if the destination file already exists. The method returns a boolean to indicate whether or not
// the file exists.
async Task<bool> WriteFileAsync<T>(string key, T value, StorageStrategies location = StorageStrategies.Local,
            CreationCollisionOption option = CreationCollisionOption.ReplaceExisting)

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Template10.Services.FileService:

Package Downloads
Template10.Services.NagService
Handy Nag Service for WinRT. Part of Template 10, a Library of Helpers for UWP.

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on Template10.Services.FileService:

Repository Stars
Windows-XAML/Template10
Making Windows 10 apps great again

Version History

Version Downloads Last updated
1.0.1 1,140 10/5/2019
1.0.0 207 9/28/2019