FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.Thumbnail;
openPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
openPicker.FileTypeFilter.Add(".jpg");
openPicker.FileTypeFilter.Add(".jpeg");
openPicker.FileTypeFilter.Add(".png");
StorageFile file = await openPicker.PickSingleFileAsync();
if (file != null)
{
// Application now has read/write access to the picked file
OutputTextBlock.Text = "Picked photo: " + file.Name;
}
else
{
OutputTextBlock.Text = "Operation cancelled.";
}
如何添加 openPicker.FileTypeFilter.Add(".*");
表示在文件选择器中显示所有文件类型?
最佳答案
您快完成了。正确的语法是 openPicker.FileTypeFilter.Add("*");
来自FileTypeFilter文档:
The File picker sample demonstrates how to show files of any type in the file picker for the user to pick from.
示例中的代码:
FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.List;
openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
openPicker.FileTypeFilter.Add("*");
关于c# - 使用文件选择器 Metro 应用程序选择所有文件 Windows 8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12757748/