c# - 使用文件选择器 Metro 应用程序选择所有文件 Windows 8

标签 c# windows-8 microsoft-metro .net-4.5

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/

相关文章:

c# - 从 HttpModule 访问 Request.Form 中断 AutoEventWireUp

c# - 在 metroapp 中显示存储在存储文件中的图片

c# - 多级语义缩放

c# - Guid.NewGuid() 在 Parallel.For 循环中使用时返回重复值

c# - 具有基于模式的 Multi-Tenancy 的 EF 核心和 ASP.NET 核心

c# - 为 PdfPDocument 文档创建一个时跳转到 iTextSharp PdfPtable 中的下一页

xaml - 为什么覆盖 ApplicationPageBackgroundThemeBrush 不起作用?

visual-studio-2010 - 在 Dropbox 中托管 Visual Studio 项目

windows-8 - 根据 WinRT 的构建配置设置应用程序图标

c# - 如何在 Windows 8 Metro App 中使用 StreamSocketListener 和 StreamSocket 而不是 System.Net.Sockets?