Domanda

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.

È stato utile?

Soluzione

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()

Altri suggerimenti

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()
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top