Forum Xamarin Xamarin.Forms

PCLStorage on UWP: "Access is denied" error

TomSoderlingTomSoderling USUniversity ✭✭✭
edited August 2016 in Xamarin.Forms

Using the PCLStorage library, any time I try to open an image file from anywhere other than the LocalState folder, I get an exception: "Access is denied"
Stack Trace:
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at PCLStorage.WinRTFileSystem.<GetFileFromPathAsync>d__0.MoveNext()

The LocalState folder is where all the files for our app live. Things like the SQLite (.db3) file, photos, videos, etc.

//var imagePath2 = @"C:\Users\Tom\AppData\Local\Packages\f736c883-f105-4d30-a719-4bf328872f5e_nh7s0b45jarrj\testPhoto.jpeg"; // up one folder var imagePath2 = @"C:\testPhoto.jpeg"; var file = PCLStorage.FileSystem.Current.GetFileFromPathAsync(imagePath2).Result;

At first I thought I was missing a Capability or something in the .appxmanifest, but there doesn't seem to be one that's appropriate:

Xamarin.Forms v2.3.1.114
PCLStorage v1.0.2
Microsoft.NETCore.UniversalWindowsPlatform v5.2.2



  • OmmyOmmy AUMember ✭✭

    @TomSoderling , I am facing the same issue, I guess PCLStorage provides only access to LocalState folder.
    If need to access the file from different location, should write a native code and call by dependency service.
    In ios/Android, I could access files from Documents folder by setting the capabilities but in UWP , I couldn't access Documents folder. Where as Download folder could be accessed in UWP without setting any capabilities.

Sign In or Register to comment.