递归删除空文件夹

 public void DeleteEmptyDir(string path)
        {
            DirectoryInfo dis = new DirectoryInfo(path);
       
            if (dis.GetDirectories().Length > 0)
            {
                for (int i = 0; i < dis.GetDirectories().Length; i++)
                {
                    DeleteEmptyDir(dis.GetDirectories()[i].FullName);
                }
            }
            FileInfo[] files = dis.GetFiles();
            if (files.Length < 1 && dis.GetDirectories().Length < 1)
            {
                dis.Delete();

            }


        }

posted on 2009-07-15 12:09 sanmao 阅读(147) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 

常用链接

留言簿(5)

随笔分类

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜