I have a program that is searching through a specified directory and its subdirectories.
I want to list for this directory and each subdirectory the names of all files that
contain a specific word, lets say for example: "duck". I will then add that file to a textbox display.
The code snippet I have, I thought should work...but I am not reading in any files. Is it how I am cheching for 'duck"? if (file.Contains("duck") )
private void listFiles(string a_directory)
// get a list of all the files directories within the directory.
string files = Directory.GetFiles(a_directory);
string directories = Directory.GetDirectories(a_directory);
foreach (string file in files)
// display only files that have gteater assecced time
if (file.Contains("duck") )
txt_results.Text += file + "\r\n";
// go through all the directories and do the same thing.
foreach (string dir in directories)
txt_results.Text += dir + "\r\n";
// call recursivly to hit all directories