For the first time, I suggest you use StopWatch instead of DateTime to get the elapsed time.
The second time, to speed up the search, you do not have to save the result of GetFiles in a list, but directly in an array.
And finally, you have to optimize your search pattern: you need every doc and docx file, try "* .doc?"
Here is my suggestion:
var sw = new Stopwatch();
sw.Start();
var matches = Directory.GetFiles(MainFolder, "*.doc?", SearchOption.AllDirectories);
sw.Stop();
MessageBox.Show(matches.Length + " matches in " + sw.Elapsed.TotalSeconds + " seconds");
source
share