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

     ClearDirectory(const char* szPath)
    {
     
     if( szPath == NULL )
      return;
     string strPath = szPath;
     if( strPath.at(strPath.length()-1) != '\\' )
      strPath.append("\\");

     string strSearch = strPath+"*";
     string strTarget;

     WIN32_FIND_DATA FindFileData;
     HANDLE hFind;
     hFind = FindFirstFile(strSearch.c_str(), &FindFileData);
     if (hFind == INVALID_HANDLE_VALUE)
     {
      DWORD dwErr = GetLastError();
      return;
     }
     do
     {
      if( !(FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
      {
       strTarget = strPath+FindFileData.cFileName;
       DeleteFile(strTarget.c_str());
      }
      else
      {
       if( 0 != strcmp(FindFileData.cFileName, ".") &&
        0 != strcmp(FindFileData.cFileName, "..") )
       {
        strTarget = strPath+FindFileData.cFileName;
        Linkwork::Win32::ClearDirectory(strTarget.c_str());
        RemoveDirectory(strTarget.c_str());
       }
      }
     } while( FindNextFile(hFind, &FindFileData) );
     FindClose(hFind);
     
    }

  • 相关阅读:
    服务器模型??
    tcp和udp详解??
    osi七层模型??
    高内聚 低耦合??
    进程和线程的区别和联系??
    2019.10.03题解
    2019.10.02题解
    2019.09.29考试报告
    2019.09.27考试报告
    2019.09.26考试报告
  • 原文地址:https://www.cnblogs.com/ahuo/p/1409474.html
Copyright © 2011-2022 走看看