递归文件夹
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.IO;
6
7 namespace 递归文件夹
8 {
9 class Program
10 {
11 static void Main(string[] args)
12 {
13 string Path = "D:\\Program Files";
14 showDir(Path);
15 Console.ReadLine();
16 }
17 private static void showDir(string parentPath)
18 {
19 foreach (string path in Directory.GetDirectories(parentPath))
20 {
21 Console.WriteLine("开始:" + Path.GetDirectoryName(path));
22 showDir(path);
23 Console.WriteLine("结束"+Path.GetDirectoryName(path));
24 }
25 }
26 }
27 }
28