Question

I have used the filter method of openFileDialogBox to allow multiple file types to be opened, but the user must select which file type they want using the dropdown. Only files with extensions matching the selected file type are visible.

How can I show all files with extensions that match any of my allowed file types? I don't want all files to be visible/openable, just the ones that I have designated.

Was it helpful?

Solution

Just specify what you want to allow... Just an example...

 Dim dlg As New OpenFileDialog()

 'Filter by Office Files
 dlg.Filter = "Office Files|*.doc;*.xls;*.ppt"

 dlg.ShowDialog()

OTHER TIPS

A small snippet of how it works

Dim result As DialogResult = New DialogResult()
        OpenFileDialog1.Filter = "Word Documents|*.doc;*.docx|PowerPoint Slides|*.ppt|Video Files|*.MP4|PDF Files|*.pdf"
        OpenFileDialog1.InitialDirectory = "C:\"
        OpenFileDialog1.FileName = ""
        result = OpenFileDialog1.ShowDialog()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top