// DirectoryInfo di = new DirectoryInfo(@"D:\Test"); // FindFile(di); static void FindFile(DirectoryInfo di) { FileInfo[] fis = di.GetFiles(); for (int i = 0; i < fis.Length; i++) { Console.WriteLine("文件:" + fis[i].FullName); } DirectoryInfo[] dis = di.GetDirectories(); for (int j = 0; j < dis.Length; j++) { Console.WriteLine("目录:" + dis[j].FullName); FindFile(dis[j]); } }