private void button1_Click(object sender, EventArgs e)
{
SearchDirectory(@"D:\My Documents");
}
public void SearchDirectory(string Path)
{
// Search the directory
DirectoryInfo di = new DirectoryInfo(Path);
FileInfo[] f = di.GetFiles();
listBox1.BeginUpdate();
foreach (FileInfo myFile in f)
listBox1.Items.Add(myFile.FullName);
listBox1.EndUpdate();
// Search its sub directories
DirectoryInfo[] d = di.GetDirectories();
foreach (DirectoryInfo myDir in d)
SearchDirectory(myDir.FullName);
}