static void Main(string[] args)
{
string folderName = @"D:\";//注意D盘下文件太多可能太耗费搜索时间,应该改成其他路径
string[] allFileNames = Directory.GetFiles(folderName, "*.txt", SearchOption.AllDirectories);
foreach (string fn in allFileNames)
Console.WriteLine(fn);
Console.ReadLine();
}