Reputation: 348
I have the following Code
var picker = new FolderPicker();
picker.FileTypeFilter.Add("*");
var pfolder = await picker.PickSingleFolderAsync();
StorageApplicationPermissions.FutureAccessList.Add(pfolder);
StorageFile file = await pfolder.GetFileAsync("Kundenliste.xml");
it is possible to give the FolderPicker
a fixed Folder? The Dialog from FolderPicker
should not pop-up, but I need to access the Folder C:\.
It is possible?
Upvotes: 0
Views: 306
Reputation: 39082
UWP apps run in a sandbox, so that the user can install them in a safe manner and doesn't have to worry about the app accessing a folder she didn't give it access to.
In this case, if you need to access the C: drive, there are two solutions depending on the version of Windows 10 you target.
If you target Fall Creators Update (1709 - 16299) or lower, you must use the FolderPicker
dialog to ask the user to pick the folder manually.
If you target the Spring Creators Update (1803 - probably 17110), you can declare the new broadFileSystemAccess
capability, which will enable your app to access any location the user has access to, but there must be a reason why your app would need such a thing, because it is evaluated during the certification process on the Microsoft Store.
In addition, if your app declares an app execution alias, it automatically gets rights to access the filesystem tree from the folder where it is launched from downwards. You don't need any special permissions for this.
Upvotes: 2