2

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 ?

Muhammad Touseef
  • 4,357
  • 4
  • 31
  • 75
  • Maybe try this method https://learn.microsoft.com/en-us/uwp/api/windows.storage.storagefolder.getfolderfrompathasync#Windows_Storage_StorageFolder_GetFolderFromPathAsync_System_String_ – An Hoa May 15 '18 at 21:07
  • @AnHoa this method asks for absolute path, what is the absolute path for a user's file system? I think there is no fixed path because each user will have their name in the path of the file system and then custom names of their local disk drives and so on. – Muhammad Touseef May 15 '18 at 22:19
  • 1
    Check this https://learn.microsoft.com/en-us/uwp/api/windows.storage.userdatapaths if you want to find the paths to user's data folders (Downloads, ...). – An Hoa May 15 '18 at 23:46

1 Answers1

0

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.

Nico Zhu
  • 32,367
  • 2
  • 15
  • 36
  • I am aware that this was not allowed before that is why I requested this feature, and now that it is allowed, it is disappointing that we dont have a straight forward method like other libraries. – Muhammad Touseef May 16 '18 at 09:49
  • which one of SystemDataPaths or userDataPaths can give me user drives, like localdisk C and localdisk D, and all other drives on that specfifc device? obviousy I dont know name of the drives on user's device so I would need access dynamically. – Muhammad Touseef May 16 '18 at 09:51
  • Currently, there is no such api could list localdisk directly. If you want list all disk, you could enumerate with hard string( C,D,E...)path. – Nico Zhu Jun 05 '18 at 08:49