i use this methode to search for every keyword in textbox1 ind have the result in the listbox2 . But the problem that the results are repeated .
this code used in search button
- private void button1_Click(object sender, EventArgs e)
- {
-
- string[] pattern = textBox1.Text.Split(new[] { ' ' },StringSplitOptions.RemoveEmptyEntries);
-
- List<DirectoryInfo> list_temporare = new List<DirectoryInfo>();
-
- listBox2.Items.Clear();
-
- foreach (DirectoryInfo dr in listBox1.Items)
- {
- list_temporare.Add(dr);
- }
-
- var liste_resultat = (from drc in list_temporare
- where pattern.All(s => drc.ToString().ToLower().Contains(s.ToLower()))
- select drc);
-
- foreach (DirectoryInfo dr in liste_resultat)
- {
- listBox2.Items.Add(dr);
- }
- }