using Windows.Storage; using Windows.Storage.Pickers; FileOpenPicker filePicker = new FileOpenPicker(); filePicker.FileTypeFilter.Add(".txt"); StorageFile selectedFile = await filePicker.PickSingleFileAsync(); if (selectedFile != null) { // do something with selected file }
using Windows.Storage; using Windows.Storage.Pickers; FileOpenPicker filePicker = new FileOpenPicker(); filePicker.FileTypeFilter.Add(".jpg"); filePicker.FileTypeFilter.Add(".png"); StorageFile selectedFile = await filePicker.PickSingleFileAsync(); if (selectedFile != null) { // do something with selected file }This example is similar to the previous one, but sets the FileTypeFilter property to filter only image files. It accepts files with the extension .jpg and .png. The package library used to use FileOpenPicker is the Universal Windows Platform (UWP) in C#.