views:

68

answers:

1

Ok so I have to create a form that takes the contents of a folder and lists it in a textbox (yes a textbox not a list box!)

I then have to filter this textbox using a combobox which contains all the extensions of the folder (e.g. if i choose ".txt" in the combobox the textbox should filter to show all the text files only!)

I've managed to do everything bar getting the combobox to filter the textbox. I can't find any help anywhere online and am new to programming so please help!

By the way i'm using c# and this is all using windows forms

+2  A: 

On the selected index changed event of the combo box, I'd rewrite the information in the text box based off of the filter selected. You can use System.IO.DirectoryInfo to filter your directory given a file extension.

StringBuilder fileNames = new StringBuilder();
DirectoryInfo dInfo = new DirectoryInfo(<string yourDirectory>);                                 
FileInfo[] fileInfo = dInfo.GetFiles("*" + <string yourChosenFileExtension>);
foreach (FileInfo file in fileInfo)
{  
   fileNames.Append(file.Name);
}
yourTextBox.Text = fileNames.ToString();
Aaron