Skip to content

File Service Plugin for Xamarin and Windows

License

Notifications You must be signed in to change notification settings

jdumasleon/FileServicePlugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

File Service Plugin for Xamarin and Windows

Library version 2.0 has been published. This nuget contais .Net Standard version of this FileService logic. New code at src.NetStandard. NugetID -> BiT21.FileService NuGet

Pending to update this README to reference the new code.

A simple way to create a file system sandbox where your aplication will be able to save information, Text, Objects or Byte[].

Setup

Platform Support

Platform TFM Version
Xamarin.Android MonoAndroid10 API 10+
Xamarin.iOS Xamarin.iOS10 iOS 7+
Windows 10 UWP UAP10 10+
.NetFramework net45 4.5+

API Usage

To gain access to the FileService class use this methord.

var f = CrossFileService.Current;

Before macking any call to FileService we need to specify the sandboxtag, that will define the sandbox we will be targeting the class calls.

f.SandboxTag = "MyAplicationSandboxTag";

This tag translates to a folder on the device FileSystem.

The original design stands that the application will be working with a single sandbox. This will change in future releases.

Thefore the initialization will stand:

IFileService fileService = FileService.CrossFileService.Current;
fileService.SandboxTag = SANDBOX_TAG;
string content = "This is the content I need to save in a text file";

//Create file and save content.
await fileService.SaveTextFileAsync(content, filename);

//Read content from file
string text = await fileService.ReadTextFileAsync(filename);
Assert.AreEqual(content, text);

//Delete file from sandbox.
await fileService.DeleteFileAsync(filename);
Assert.IsFalse(await fileService.ExistFileAsync(filename));

//Delete sandbox
await fileService.DeleteSandboxAsync();
Assert.IsFalse(await fileService.ExistSandBoxAsync());

Roadmap

Planning to extend the plugin with

  • Multi sandbox
  • Encrypted storage. On Test proyect you have a sample to use FileService in combination wth BiT21.EncryptDecrypt to protect file data.

Platform specifics

Sandbox will be created

Platform Path
iOS Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
Xamarin.Android Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
Windows_UWP Windows.Storage.ApplicationData.Current.LocalCacheFolder.Path;

Contributions

Contributions are welcome! If you find a bug please report it and if you want a feature please report it.

If you want to contribute code please file an issue and create a branch off of the current dev branch and file a pull request.

License

Under MIT, see LICENSE file.

About

File Service Plugin for Xamarin and Windows

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 99.6%
  • Other 0.4%