12

I'm trying to use broadFileSystemAccess Capability for UWP apps, But broadFileSystemAccess capability is not listed in my list of capabilites in Package.appxmanifest.

My min and max target version is 1803, build 17134, Please help me with this.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
Saravana Kumar
  • 341
  • 3
  • 14

1 Answers1

22

This capability is not listed in the "designer" of Package.appxmanifest, you have to add it manually via code.

Go to Solution Explorer and right-click Package.appxmanifest. Select View Code.

In the code view update the Package element to contain the following:

<Package
  ...
  xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
  IgnorableNamespaces="uap mp rescap">

Do not duplicate the IgnorableNamespaces attribute, just append rescap to the end of its value. Now scroll down below and find <Capabilities>. Inside add the broadFileSystemAccess capability as follows:

<rescap:Capability Name="broadFileSystemAccess" />
Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
  • is there any API that can provide us search across the filesystem for the given file name. – Saravana Kumar May 29 '18 at 04:55
  • 2
    Sorry for not noticing your problem. You can use StorageFilder.CreateFileQueryWithOptions with an instance of QueryOptions to search. There is a lot of properties which you can configure. https://learn.microsoft.com/en-us/uwp/api/windows.storage.storagefolder.createfilequerywithoptions – Martin Zikmund Jan 10 '19 at 15:10
  • I tried to do this in a xamarin forms application and then access my documents and I get System.UnauthorizedAccessException: 'Access to the path. my min and target version are 10.0.17763.0 10.0.16299.0 – Jose Manuel Ojeda Jan 25 '19 at 16:40
  • 2
    How are you trying to access the files? You must actually use StorageFile APIs, not just classic System.IO API – Martin Zikmund Jan 25 '19 at 22:27
  • 2
    This answer does not appear to work as-written. I've followed the steps in the answer exactly but cannot use, `await Windows.Storage.StorageFolder.GetFolderFromPathAsync("C:\\Users\\user name")` without `E_ACCESSDENIED` getting thrown. – kayleeFrye_onDeck Aug 02 '19 at 20:58
  • 9
    I really can't understand why these stupid exceptions exist. Why on earth some capabilities are present in the GUI and some other must be added, by hand, through the code? Damn. – Filipe Madureira Oct 31 '19 at 09:36
  • This answer really a big live safer, since I'm newbie in UWP world I never know this exist. Thanks! – ichan-akira May 07 '20 at 07:54
  • Is there any way I could enable just for development and automatically have it disabled for release build? – Nick Aug 06 '21 at 19:09
  • 1
    @Nick not automatically per se, you would have to adjust the `Package.appxmanifest` file - either using two different manifests (one for development, one for release), or updating removing the capability before build (which is doable for example as part of a build pipeline) – Martin Zikmund Aug 08 '21 at 15:12
  • I had to add also the runFullTrust capability besides the broadFileSystemAccess to get full File Access – Filipe Madureira Oct 15 '21 at 20:10