遞歸刪除空文件夾

           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 閱讀(154) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發(fā)表評論。


          網(wǎng)站導航:
           

          常用鏈接

          留言簿(5)

          隨筆分類

          隨筆檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 夹江县| 仙桃市| 孟村| 闽侯县| 门头沟区| 门源| 淮阳县| 乌苏市| 新巴尔虎右旗| 元氏县| 赤壁市| 河池市| 上虞市| 武义县| 德清县| 桐庐县| 蓬莱市| 云阳县| 双流县| 兴安县| 望城县| 洞头县| 晋州市| 什邡市| 绥中县| 区。| 永泰县| 阿拉尔市| 来凤县| 古交市| 衡山县| 兴城市| 石首市| 大安市| 沾益县| 阿巴嘎旗| 呼图壁县| 赣榆县| 金门县| 沂水县| 新兴县|