You can also use the Launcher.LaunchFolderAsync
and use the second parameter FolderLauncherOptions
too.
FolderLauncherOptions
can make the file or folder that you want to select that use the ItemsToSelect
.
ItemsToSelect
is a read-only property, but you can add items to the existing list.
Here's an example, getting a folder using FolderPicker
and then selecting all files:
The first is get the folder:
FolderPicker p = new FolderPicker();
p.FileTypeFilter.Add(".txt");
StorageFolder folder = await p.PickSingleFolderAsync();
And then get all files in the folder
foreach (var temp in await folder.GetFilesAsync())
I can use FolderLauncherOptions to add the item that I want to select.
var t = new FolderLauncherOptions();
foreach (var temp in await folder.GetFilesAsync())
{
t.ItemsToSelect.Add(temp);
}
Then open the file explorer
await Launcher.LaunchFolderAsync(folder, t);
You can see that the explorer will be opened while selecting all files.
You can also add folders to the ItemsToSelect and it will be selected.
See here for more details: https://learn.microsoft.com/en-us/uwp/api/Windows.System.Launcher#Windows_System_Launcher_LaunchFolderAsync_Windows_Storage_IStorageFolder_Windows_System_FolderLauncherOptions_