Search code examples
c#uwpfilepickerfilefilter

UWP File Picker FileTypeFilter Exception


I have a very simple question, but is there a way while using a FilePicker in a UWP app to specify a file filter such as "All files except .exe and .pdf"?

I know to specify only a filter for these files you would use:

openPicker.FileTypeFilter.Add(".exe");  
openPicker.FileTypeFilter.Add(".pdf");

Or to include all files you would use:

openPicker.FileTypeFilter.Add("*");  

So is there a way to specify * except .exe and .pdf?


Solution

  • No. It's much more common to only accept a few types or, genuinely, anything.
    If you really can accept anything apart from .exe and .pdf then accept anything and then validate after the file is selected.