0

I want to do this:

openfiledialog filter doesn't show folders. just show the files. is it possible?

this code at the below, show me the folders and the images files. I want to filter folders too.

file.Filter = "İmage files |*.jpg;*.png;*.gif;*.jpeg*";
file.FilterIndex = 1;
  • 1
    If all you want is a list of files, then consider just creating a form with a list box, populating it with the files from the path that you have obviously preordained. – LarsTech May 18 '15 at 22:22
  • just I want to hide folders in openfiledialog form. – zorbey aslan May 19 '15 at 22:32

1 Answers1

0

Folders are filtered by *. (no extension)

Fabian Stern
  • 376
  • 1
  • 9
  • Image Files|*.jpg;*.png;*.gif;*.jpeg|Folders|*.|All Files|*.* – Fabian Stern May 18 '15 at 22:10
  • 1
    That's nonsense, folders can have an extension as well. Nor it is helpful in any way. – Hans Passant May 18 '15 at 22:20
  • It's not nonsense, I just did not get him. It is not possible to hide folders. You could check using System.IO.Directory.Exists(ofd.Filename) and revert the selection. And Folders always have no extension at all in the Windows world. – Fabian Stern May 18 '15 at 22:29
  • thats right zorbey, I misunderstood you the first time and thought you want explicitly SHOW folders. But you want to hide them ;) I think there is no Filter for this. You could check the ofd.Filename for being a directory and then simply ignore the users selection and reshow the dialog. Otherwise I just know how to send a WM_MESSAGE to delete a listview item, but this would make mountains out of molehills – Fabian Stern May 18 '15 at 22:46