3
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(".*"); 意味着在文件选择器中显示所有文件类型?

4

1 回答 1

4

你快到了..正确的语法是openPicker.FileTypeFilter.Add("*");

FileTypeFilter文档:

文件选择器示例演示了如何在文件选择器中显示任何类型的文件以供用户选择。

示例中的代码在哪里:

FileOpenPicker openPicker = new FileOpenPicker();
openPicker.ViewMode = PickerViewMode.List;
openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
openPicker.FileTypeFilter.Add("*");
于 2012-10-06T07:49:15.377 回答