Hi @杨岑 ,
Is this possible in UWP?
Yes, this is possible.
It needs StorageFile.GetParentAsync and Launcher.LaunchFolderAsync. But you need to add the restricted broadFileSystemAccess capability for your app.
After the application is deployed, open the Settings > Privacy&security > File system, find the app and turn on the file system access.
Windows.Storage.StorageFile file;
private async void Button_Click_Show(object sender, RoutedEventArgs e)
{
StorageFolder folder = await file.GetParentAsync();
await Launcher.LaunchFolderAsync(folder);
}
private async void Button_Click_Select(object sender, RoutedEventArgs e)
{
var picker = new Windows.Storage.Pickers.FileOpenPicker();
picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
picker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
picker.FileTypeFilter.Add(".jpg");
picker.FileTypeFilter.Add(".jpeg");
picker.FileTypeFilter.Add(".png");
file = await picker.PickSingleFileAsync();
if (file != null)
{
Debug.WriteLine("Picked photo: " + file.Name);
}
else
{
Debug.WriteLine("Operation cancelled.");
}
}
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.