static void Main(string[] args) { DirectoryInfo di = new DirectoryInfo(@"E:\001"); FindFile(di); Console.Read(); } // DirectoryInfo di = new DirectoryInfo(@"D:\Test"); // FindFile(di); static void FindFile(DirectoryInfo di) { FileInfo[] files = di.GetFiles(); for (int i = 0; i < files.Length; i++) { Console.WriteLine("文件:" + files[i].FullName); } DirectoryInfo[] dirs = di.GetDirectories(); for (int i = 0; i < dirs.Length; i++) { Console.WriteLine("目录:" + dirs[i].FullName); FindFile(dirs[i]); } }