FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.List;
openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
openPicker.FileTypeFilter.Add("*");
IReadOnlyList files = await openPicker.PickMultipleFilesAsync();
if (files.Count > 0)
{
// Application now has read/write access to the picked file(s)
foreach (StorageFile file in files)
{
...
}
}
FolderPicker folderPicker = new FolderPicker();
folderPicker.SuggestedStartLocation = PickerLocationId.Desktop;
folderPicker.FileTypeFilter.Add(".docx");
folderPicker.FileTypeFilter.Add(".xlsx");
folderPicker.FileTypeFilter.Add(".pptx");
StorageFolder folder = await folderPicker.PickSingleFolderAsync();
if (null != folder)
{
// Application now has read/write access to all contents in the picked folder (including other sub-folder contents)
StorageApplicationPermissions.FutureAccessList.AddOrReplace("PickedFolderToken", folder);
...
}
FileSavePicker savePicker = new FileSavePicker();
savePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
// Dropdown of file types the user can save the file as
savePicker.FileTypeChoices.Add("Microsoft Word Document", new List(){".docx", ".doc"});
savePicker.FileTypeChoices.Add("Plain Text", new List(){".txt"});
// Default extension if the user does not select a choice explicitly from the dropdown
savePicker.DefaultFileExtension = ".docx";
// Default file name if the user does not type one in or select a file to replace
savePicker.SuggestedFileName = "New Document";
StorageFile savedItem = await savePicker.PickSaveFileAsync();
if (null != savedItem)
{
...
}