How to enable DocumentLibrary feature in a Windows Store (WinRT) application?

I just created a new XAML / C # application for the Windows Store in Visual Studio. I tried to create a file in the Documents folder using this code:

// DEBUG ONLY: StorageFile file = await KnownFolders.DocumentsLibrary.CreateFileAsync("Hey lol.txt"); 

But he throws this exception (which I expected):

WinRT Information: Access to a specified location (DocumentsLibrary) requires the ability to declare in the manifest.

This is normal. I was expecting this. So I go to Package.appxmanifest and go to the Capabilities tab, and, to my surprise, there is no “DocumentLibrary” feature.

How to enable it if it does not exist yet?

enter image description here

+6
source share
4 answers

Looks like your answer is here . The author shows that he is available in VS2012, but left the list in VS2013, referring to the MS policy against access to this particular folder.

[Although] this feature only disappeared from the user interface, you can still open the appxmanifest source and manually add this feature. The result is likely to be the same as before - the failure of certification for individual developers, so you better stay away from this trick. Microsoft strongly recommends that you do not use the capabilities of the Document Library by offering Folder and File Pickers instead.

+6
source

According to the response to the grant, this method is to add the opportunity manually.

Right-click the Package.appxmanifest file in Solution Explorer and select View Code, then either find the Capabilities element or add it yourself:

 ... <Capabilities> <Capability Name="internetClient" /> <Capability Name="removableStorage" /> <Capability Name="documentsLibrary" /> </Capabilities> </Package> 
+3
source

Here's what you get from the Windows Store when you try to publish it.

enter image description here

+3
source

Since this is a UAP, syntax should indicate this, follow

  <Capabilities> <Capability Name="internetClient" /> <uap:Capability Name="documentsLibrary" /> </Capabilities> 

You need to add "uap:" before Capability

0
source

All Articles