FileDialog FileFilter lists entries beyond filefilter


Well-Known Member
Licensed User
Longtime User
Dear All,

using FileDialog as filenameDialog.FileFilter = ".db", lists all entries with extension starting with .db:

This seems more a filefilter like = .db* or .db%.

Is there a way to prevent listing the additional files, and list only the file1.db.


Well-Known Member
Licensed User
Longtime User
Thanks agraham.

Instead of filedialog, have made a simple inputlist routine to select a .db file.
May be of use to others as well.

Sub SelectDatabaseFile(sTitle As String, sDir As String, sPath As String) As String
' Select a new database file (extension .db)
   Dim lstFiles As List         
   Dim fileSelected As String = ""
   Dim idSelected As Int            
   Dim sFile As String
   lstFiles.Initialize              ' Init the list and then use addall,
   lstFiles.AddAll(File.ListFiles(sDir)) ' Ensures removeat working properly
   If (lstFiles.Size > 0) Then
      ' Cleanup list resulting in listing only files with extension .db
      For i = lstFiles.Size - 1 To 0 Step -1
         sFile = lstFiles.Get(i)
         If sFile.EndsWith(".db") = False Then lstFiles.RemoveAt(i)
      idSelected  = InputList(lstFiles, sTitle, -1)   
      If idSelected <> DialogResponse.CANCEL Then fileSelected = lstFiles.Get(idSelected)
   End If
   Return fileSelected
End Sub
Last edited:
Upvote 0