zoukankan      html  css  js  c++  java
  • 递归删除目录

    BOOL DeleteFolder(CString strFolder,BOOL bSelf/*=TRUE*/)
    {
        CFileFind finder;
        CString strWildcard(strFolder);
        strWildcard += _T("\*.*");
        BOOL bWorking = finder.FindFile(strWildcard);
        if (!bWorking)
        {
            finder.Close();
            return FALSE;
        }
        BOOL bSuc=TRUE;
        while(bWorking)
        {
            bWorking = finder.FindNextFile();
            if (finder.IsDots())
                continue;
            if (finder.IsDirectory())
            {
                CString str = finder.GetFilePath();
                if (!DeleteFolder(str,TRUE))
                {
                    bSuc = FALSE;
                    break;
                }
            }
            else
            {
                CString str = finder.GetFileName();
                str = strFolder + _T("\") + str;
                BOOL bSuccess = ::DeleteFile(str);
                if (!bSuccess)
                {
                    bSuc = FALSE;
                    break;
                }
            }
        }
        finder.Close();
        if (bSuc && bSelf)
        {
            bSuc = ::RemoveDirectory(strFolder);
        }
        return bSuc;
    }
  • 相关阅读:
    01
    py5.30
    py 5.28
    py5.25
    py 5.24
    py 5.22
    py5.21
    py 5.18
    py 5.17
    py 5.16
  • 原文地址:https://www.cnblogs.com/nkzhangkun/p/3501870.html
Copyright © 2011-2022 走看看