no api for file system even with broadFileAccess in uwp

417 views Asked by At

I am trying to create a File Explorer like uwp app, it will be an app like traditional file explorer in windows 10 but it will mainly show only video files, so for that I want to use BroadFileAccess capability. Usually when I use a capability related to FileAccess I have a simple API like KnownFolders.VideoLibrary and others like that to get the root folder of that library, but in this case broadfileacccess claims to give access to complete file system which is available to the user, but in the docs there is not a single method or api reference something likeKnownFolders.FileSystem which can give us the root folder of the file system of the user so we can build apps like file explorer etc. How can I actually go on and use this broadFileAccess capability if there is not even a api method to use it ?

1

There are 1 answers

3
Nico Zhu On

From official document:

This is a restricted capability. On first use, the system will prompt the user to allow access. Access is configurable in Settings > Privacy > File system. If you submit an app to the Store that declares this capability, you will need to supply additional descriptions of why your app needs this capability, and how it intends to use it. This capability works for APIs in the Windows.Storage namespace

Currently, it does not provide proprietary Windows.Storage API. But you could use present Windows.Storage API to get higher access. For example, you could invoke GetFolderFromPathAsync method with absolute path(@"D:\PersonImages"). You could use GetFolderFromPathAsync with SystemDataPaths or UserDataPaths.

var folder = await StorageFolder.GetFolderFromPathAsync(UserDataPaths.GetDefault().Desktop);

Prior to this, this kind of access was illegal.