Phlipp Geyer

Phlipp Geyer

  • NA
  • 1
  • 1.4k

Search in directory

Apr 13 2012 8:44 AM
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)