文件夹嵌套, 有什么办法把它们删了?一个文件夹下又有文件夹, 一层文件夹套一层文件夹. 删除不了.有什么办法把它们删了?

解决方案 »

  1.   

    system("rd /s /q 文件夹路径");
      

  2.   


    void CPcDelDirDlg::OnBnClickedButton1()
    {
    system("rd /s /q e:\00");
    }删不了.......
      

  3.   

    给你提供个函数
    BOOL DeleteTargetFolder(LPCTSTR lpstrPath)
    {
    CString strRootPath(lpstrPath);
    if (strRootPath[strRootPath.GetLength()-1] != '\\')
    strRootPath = strRootPath + _T("\\"); CFileFind mFinder;
    BOOL bFind = mFinder.FindFile(strRootPath + _T("*.*"), 0); //如果指定文件类型的话,只能在本目录中遍历(find不到文件夹)
    while (bFind){
    bFind = mFinder.FindNextFile();
    if (mFinder.IsDots()){//.当前目录  ..父目录
    continue;
    }else{
    if (mFinder.IsDirectory()){
    //目标是目录
    DeleteTargetFolder(mFinder.GetFilePath());
    }else{
    //目标是文件
    DeleteFile(mFinder.GetFilePath());
    }
    }
    }
    mFinder.Close();
    RemoveDirectory(strRootPath); //一定要放在 mFinder.Close(); 的下面,否则删除失败,提示文件夹正被使用中 return TRUE;
    }
    如果有文件是只读属性的话再自己处理下SetFileAttributes去掉只读属性删掉
      

  4.   


    LS 的函数可删除有限级目录.
    但以下这个目录删除不了.(不知这个目录有没有尽头)E:\00\demo\sphinx4\src\apps\edu\cmu\sphinx\demo\sphinx4\src\apps\edu\cmu\sphinx\demo\sphinx4\src\apps\edu\cmu\sphinx\demo....
      

  5.   

    Windows下的目录深度是有限制的,到最后一层目录,完整的路径字符数不能超过260个,即MAX_PATH。如果你这里是没完没了可以进入,说明你的文件系统或目录表已经损坏了,当然会删不了。
    你现在要做的是找个工具检查你的硬盘,修复文件分配表和目录表,否则,解决不了你的问题
      

  6.   

    从描述上来看,这个问题和C++没有关系,应该放到 Windows专区去咨询一下