Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileOpenPicker with no FileTypeFilter in windows 8 apps

I need a FileOpenPicker without any FileTypeFilter !! When i do not add any FileTypeFilter then it gives an exception like : "The FileTypeFilters property must have at least one file type filter specified." But I need to see al types of files in the 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);
}

Can anyone help me out?

like image 334
Mushfiq Avatar asked Nov 12 '12 18:11

Mushfiq


2 Answers

Use:

fileOpenPicker.FileTypeFilter.Add("*");

To be able to select any type.

like image 102
Philip Rieck Avatar answered Nov 15 '22 13:11

Philip Rieck


FileOpenPicker.FileTypeFilter - Gets the collection of file types that the file open picker displays.

    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);
    }
like image 25
SFO Developer Avatar answered Nov 15 '22 12:11

SFO Developer