Search code examples
c#windows-phone

Access is denied error windows phone 8


I am getting error on following line

StorageFolder picturesFolder = KnownFolders.PicturesLibrary;

Exception is: ex {System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) at Windows.Storage.KnownFolders.get_PicturesLibrary() at WinTooth.MainPage.d__0.MoveNext()} System.SystemException {System.UnauthorizedAccessException}

I have also added lines to register for a file association extension. Please suggest/help.


Solution

  • http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.knownfolders.pictureslibrary says Windows Phone 8: This API is not intended to be used directly from your code.

    In my app I used

                 var photoChooserTask = new PhotoChooserTask();
                 photoChooserTask.Completed += OnPhotoChooserTask_Completed;
                 photoChooserTask.Show();
    

    to pick a photo.