目录结构如下
My
   A 
      1
         vvv
         zzz (包含有文件)
             
   B
      2   C  
      3(包含有文件)
-----------------我的意思是要删除。所有没有包含文件的目录   
上面的目录结构,结果应该如下: 怎么实现?My
   A 
      1
         zzz (包含有文件)
   C 
      3(包含有文件)

解决方案 »

  1.   

    写了个控制台程序, 没详细测试.static void Main(string[] args)
    {
        string path = @"C:\Documents and Settings\JinLidong\桌面\ConsoleApplication1\a";
        DeleteFolder(path);    Console.WriteLine("press any key to exit...");
        Console.ReadKey();
    }public static void DeleteFolder(string path)
    {
        string[] folders = Directory.GetDirectories(path);
        foreach (string path1 in folders)
        {
            DeleteFolder(path1);
        }    if (Directory.GetFiles(path).Length == 0 && Directory.GetDirectories(path).Length == 0)
            Directory.Delete(path);
    }