mercredi 7 avril 2021

c# Search for a specific file by partial match then do something with it

I tried this code, but it shows nothing when entering part of the file name.

string pattern = txtFilter.Text;

string[] files = Directory.GetFiles(txtSourcePath.Text, ("*" + pattern + "*"), 
                                    SearchOption.AllDirectories);

foreach (var file in files)
{
   txtResults.Text += file + "\n";
}

Aucun commentaire:

Enregistrer un commentaire