Update:
I want to create a folder in C drive from my UWP app. I modified your code a little bit. The following code creates a folder named
AAA
in C driver and add it to the future access list with tokenAAA
. You could try it.
string folderPath = @"C:";
// Get the StorageFolder from the path
StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(folderPath);
var targetfolder= await folder.CreateFolderAsync("AAA");
// Add the folder to FutureAccessList with the folder path as the token
string token = "234"; // You can customize the token if needed
StorageApplicationPermissions.FutureAccessList.AddOrReplace(token, targetfolder);
Old:
I created a test folder in C first and then created a blank UWP project to test your code. I got different behaviors with the code. Enabled the capability both in the project and system setting.
Frist is that the folderPath
is not correct. It should be @"C:\RGNEW"
. After changing the path. GetFolderFromPathAsync
works correctly.
Second, FutureAccessList.AddOrReplace
will give a parameter error if you use path as token. Using RGNEW
as token works.