I have this code:

string[] dirs = Directory.GetFiles(@"c:\myFolder\", "*.doc");

How do I do the same code, if I change "*.doc" with the comboBox. I have done the code that a user selects a filter from the comboBox.
I did:

string[] dirs = Directory.GetFiles(@"c:\myFolder\", comboBox1.SelectedItem.ToString());

but it is not working... it doesn`t fill the aray dirs (in the 1st upper case it does)!

Check the value of your comboBox1.SelectedItem.ToString() . My guess it isn't what you think: "*.doc". Have you defaulted the selection before using (eg. SelectedIndex = 0)? Also, you can just use the ComboBox.Text Property to access the selected item's text as displayed in the combobox.

Correct. Take a look at this pic: I got 2 values inside an Item:
http://www.file.si/files/bqoc75hwx084p4wz3mmo.jpg"]http://www.file.si/files/bqoc75hwx084p4wz3mmo.jpg"]http://www.file.si/files/bqoc75hwx084p4wz3mmo.jpg

In comboBox1.SelectedItem I have as an Item "AvtoKrka.FilterDatotek" - this is "MyNameSpace.Class_FileFilter". And this I would say is incorect.
I would need to have in selectedItem ONLY DocumentFilter (Filter Dokumenta) which is "*.doc". Don`t you think?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.