【问题标题】:Select all files with file picker metro apps windows 8使用文件选择器 Metro 应用程序 Windows 8 选择所有文件
【发布时间】:2012-10-06 07:30:04
【问题描述】:
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(".*"); 表示在文件选择器中显示所有文件类型?

【问题讨论】:

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


    【解决方案1】:

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

    来自FileTypeFilter 文档:

    File picker sample 演示了如何显示任何类型的文件 供用户选择的文件选择器。

    示例代码在哪里:

    FileOpenPicker openPicker = new FileOpenPicker();
    openPicker.ViewMode = PickerViewMode.List;
    openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
    openPicker.FileTypeFilter.Add("*");
    

    【讨论】:

    • 什么鬼……!!!我怎么会从示例代码中错过它。感谢@nemesv 的帮助。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-23
    • 1970-01-01
    • 2016-03-10
    相关资源
    最近更新 更多