1

I would like to add some checks to my OpenFileDialog to show All files except .exe and .jar.

  var openFileDialog = new Microsoft.Win32.OpenFileDialog
            {
                Title = @"Upload File",
                Filter =
                    @"All Files|*.*|Text File (.txt)|*.txt|Word File (.docx ,.doc)|*.docx;*.doc|PDF (.pdf)|*.pdf|Spreadsheet (.xls ,.xlsx)|  *.xls ;*.xlsx|Presentation (.pptx ,.ppt)|*.pptx;*.ppt",
                FilterIndex = 1,
                RestoreDirectory = true
            };

The all files options allows All files . Not just all files of the type specified after . If the user selects one type , ssay .txt from the drop down , the other files are not shown. But the all files option shows ALL files including exe and jar.

I want to implement an option where I specifiy 5 file types , like above , and the All files option simply shows all the 5 file types together instead of ALL file types.

Wesley Lomax
  • 2,067
  • 2
  • 20
  • 34
Ace McCloud
  • 798
  • 9
  • 27
  • 2
    Not an exact duplicate, but this should answer your question. http://stackoverflow.com/questions/4710881/multiple-file-extensions-in-openfiledialog – Broots Waymb Sep 30 '15 at 15:56

1 Answers1

3

Since the filter for All Files is *.* all file types are shown, naturally... You can work around by specifying the filter for All Files like

Filter = @"All Files|*.txt;*.docx;*.doc;*.pdf*.xls;*.xlsx;*.pptx;*.ppt|Text File (.txt)|*.txt|Word File (.docx ,.doc)|*.docx;*.doc|PDF (.pdf)|*.pdf|Spreadsheet (.xls ,.xlsx)|  *.xls ;*.xlsx|Presentation (.pptx ,.ppt)|*.pptx;*.ppt"
schroeder
  • 153
  • 9