Search code examples
c#windows-8windows-runtimemicrosoft-metrowindows-store-apps

Exception of Unauthorized while using MostRecentlyUsedList in metro apps


I am working with Store apps using C#. I am using StorageApplicationPermissions.MostRecentlyUsedList to load Local Epub files. After getting those file as a Storage file.

string EpubPathToken= Windows.Storage.AccessCache.StorageApplicationPermissions.MostRecentlyUsedList.Add(file);
StorageFile file = await StorageApplicationPermissions.FutureAccessList.GetFileAsync(EpubPathToken);
Extraction(file);

While Extracting the Epub file as Zip to Package folder using ApplicationData I am getting an Exeption of Unauthorized.

Here's screen shot of error

Why because If I use the same code using from KnownFolders like Pictures Library the Extraction is working Fine.

Can any one give me any idea about this ?


Solution

  • Finally I solved the issue of getting exception of Unauthorized With the use of Blog

    I changed the code snippet according to my requirement.

    The source of code describes writes bytes of file in ZipArchiveEntry, hence I used a helper method GetByteFromFile(), which takes StorageFile object and returns me byte[] array.

    Finally thanks to Xyroid