0

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

2
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by Mitja Bonca
0

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.

Edited by DdoubleD: n/a

0

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?

Edited by Mitja Bonca: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.