broadFileSystemAccess UWP
Asked Answered
U

1

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.

Uzbek answered 28/5, 2018 at 5:40 Comment(0)
I
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" />
Ian answered 28/5, 2018 at 7:7 Comment(10)
is there any API that can provide us search across the filesystem for the given file name.Uzbek
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. learn.microsoft.com/en-us/uwp/api/…Ian
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 <TargetPlatformVersion>10.0.17763.0</TargetPlatformVersion> <TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>Godsey
How are you trying to access the files? You must actually use StorageFile APIs, not just classic System.IO APIIan
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.Ambrosius
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.Bighead
This answer really a big live safer, since I'm newbie in UWP world I never know this exist. Thanks!Meares
Is there any way I could enable just for development and automatically have it disabled for release build?Arsenopyrite
@Arsenopyrite 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)Ian
I had to add also the runFullTrust capability besides the broadFileSystemAccess to get full File AccessBighead

© 2022 - 2024 — McMap. All rights reserved.