1
Answer

Search in directory

Phlipp Geyer

Phlipp Geyer

12y
1.2k
1
Sorry about my English :)

I search a word from textbox1 in a directory. When i type for example "c" in my textbox1, a listbox shows me all entries that begin with c. (Computer, Control Panel, etc..) What can I do that this listbox shows me all other entries where the letter c is included. (e.g.: abc, helloc,...)

I hope you understand my problem :)


This is my Code:

 try
            {
                string test;
                test = textBox1.Text.ToString();
                string[] dirs = Directory.GetFiles(@"c:\", test + "*");
                foreach (string dir in dirs)
                {
                    listBox2.Items.Add(dir.ToString());


                }
            }
            catch (Exception)
            {
            }


Thank you, Philipp



EDIT: I've got it :) 

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



Answers (1)