Search code examples
c#xamarinxamarin.formsxamarin.android.net-standard

Xamarin - IO operations fail when using PCLStorage mirrors


so I'm trying to access the file system on a Xamarin Forms project, I used several projects including:

StandardStorage

StorageEverywhere

XamFileStorageNetStandard

All are Net Standard mirrors of PCL Storage, no code change is required.

I can grab the current file system from my Forms project and grab the root folder of the local storage, response is something like:

"/data/user/0/com.companyname.APPNAME/files"

When I try to perform any operation on this path, E.G:

await FileUtility.RootFolder.CreateFolderAsync("test", CreationCollisionOption.FailIfExists);
await FileUtility.RootFolder.GetFoldersAsync();
await FileUtility.RootFolder.CreateFileAsync("test.txt", CreationCollisionOption.FailIfExists);

All operations just block and never return, tested on a OnePlus 6T.

Anyone knows a solution for this?

Thanks in advance.

UPDATE: Clarify that the libraries were referenced also on the platform specific projects as required.


Solution

  • For those who will have problems in the future, simply use System.IO for handling files, apparently it works.

    Environment.SpecialFolder.LocalApplicationData
    

    Use it for accessing your app's local storage.