9 ratings
  • 1
  • 2
  • 3
  • 4
  • 5
5 star 7
4 star 0
3 star 2
2 star 0
1 star 0
Compatible with
  • Windows
  • iOS
  • Android

File System Plugin for Xamarin and Windows 1.0.2.2

Xamarin Inc

The File System Plugin for Xamarin and Windows provides a consistent, portable set of local file IO APIs for Windows Phone, Xamarin.iOS and Xamarin.Android.

File System Plugin for Xamarin and Windows details

The File System Plugin for Xamarin and Windows provides a consistent, portable set of local file IO APIs for .NET, Windows Phone, Windows Store, Xamarin.iOS, Xamarin.Android, and Silverlight. This makes it easier to create cross-platform .NET libraries and apps.

Different .NET platforms have different APIs for accessing the file system or an app-local persisted storage area. The full .NET Framework provides the standard file and directory APIs (in the System.IO namespace), Silverlight and Windows Phone provide isolated storage APIs, and WinRT provides storage APIs in the Windows.Storage namespace.

Here is a sample showing how you can use the File System Plugin for Xamarin and Windows to create a folder and write to a text file in that folder:

public async Task CreateRealFileAsync()
{
    // get hold of the file system
    IFolder rootFolder = FileSystem.Current.LocalStorage;

    // create a folder, if one does not exist already
    IFolder folder = await rootFolder.CreateFolderAsync("MySubFolder", CreationCollisionOption.OpenIfExists);

    // create a file, overwriting any existing file
    IFile file = await folder.CreateFileAsync("MyFile.txt", CreationCollisionOption.ReplaceExisting);

    // populate the file with some text
    await file.WriteAllTextAsync("Sample Text...");
}

APIs

The primary APIs in the File System Plugin for Xamarin and Windows are the IFile, IFolder, and IFileSystem interfaces. The APIs should be mostly self-explanatory and should feel very familiar if you have used the WinRT storage APIs.

The IFileSystem interface is the main API entry point. You can get an instance of the implementation for the current platform with the FileSystem.Current property.

Release Notes

Version 1.0.2.2

  • Updated sample to Xamarin.Forms 2.0
Write a Review

5 reviews

Learn Everything rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

I tried it for SQLiteDatabase and it works...

var dbPathCustomFolder = Path.Combine(SQLiteFolder.Path, filename) public static SQLiteConnection DbConnectionCustomFolder(string fileName, IFolder SQLiteFolder) { return new SQLiteConnection(DBPathCustomFolder(fileName, SQLiteFolder)); }

Posted on: November 6 / Version: 1.0.2.2
Andrei Kovalev

This is really great plugin, but there are some troubles with saving files, different from txt. So it would be great to see some samples, how to save pictures or PDF files on the device. Thanks.

Posted on: May 5 / Version: 1.0.2.2
David McCarter rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

Would be nice to have instructions on how to install plugin.

Posted on: March 4 / Version: 1.0.2.2
Kévin Jalais rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

OBSOLETE !

Does not work since Xamarin.Forms 2 update. The whole app crash without any specific error message.

EDIT

I spoke too fast :( The library works like a charm !

My problem was that since Xamarin Forms 2 i compiled my app in Android API 23 where i had to implement the "Runtime Permissions". Since there were no specific error message i thought it was a compatibility problem between Forms and PCLStorage.

I implemented the excellent Plugin.Permissions (https://github.com/jamesmontemagno/Xamarin.Plugins/blob/master/Permissions/README.md) from James Montemagno and all works now.

I changed the rate i gave initially from 1 to 5 stars. All my excuses to people who saw my comment before edit part.

Posted on: February 17, 2016 / Version: 1.0.2.1
Matthew Leibowitz rates this with
  • 1
  • 2
  • 3
  • 4
  • 5

The simple fact that I can work with files in a PCL, without having to worry about what is really happening, is totally awesome!

Posted on: February 19, 2015 / Version: 1.0.2