5

我需要一个没有任何 FileTypeFilter 的 FileOpenPicker !!当我不添加任何 FileTypeFilter 时,它会给出如下异常:“FileTypeFilters 属性必须至少指定一个文件类型过滤器。” 但我需要在 FileOpenPicker 中查看所有类型的文件!

FileOpenPicker fileOpenPicker = new FileOpenPicker();
fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;
//fileOpenPicker.FileTypeFilter.Add(".txt"); I dot not need any filter !!
fileOpenPicker.CommitButtonText = "Select Files";
fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
IReadOnlyList<StorageFile> files =await fileOpenPicker.PickMultipleFilesAsync();

List<string> fileList = new List<string>();
StringBuilder sb = new StringBuilder();
foreach (StorageFile file in files)            
{
    fileList.Add(file.Name);
    sb.AppendLine(file.Name);
}

谁能帮我吗?

4

2 回答 2

10

采用:

fileOpenPicker.FileTypeFilter.Add("*");

能够选择任何类型。

于 2012-11-12T18:44:09.207 回答
1

FileOpenPicker.FileTypeFilter - 获取文件打开选择器显示的文件类型的集合。

    FileOpenPicker fileOpenPicker = new FileOpenPicker();
    fileOpenPicker.ViewMode = PickerViewMode.Thumbnail;
    fileOpenPicker.FileTypeFilter.Add("*");
    fileOpenPicker.CommitButtonText = "Select Files";
    fileOpenPicker.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
    IReadOnlyList<StorageFile> files =await fileOpenPicker.PickMultipleFilesAsync();

    List<string> fileList = new List<string>();
    StringBuilder sb = new StringBuilder();
    foreach (StorageFile file in files)            
    {
        fileList.Add(file.Name);
        sb.AppendLine(file.Name);
    }
于 2012-11-12T20:50:00.137 回答