[MFC] VC delete directories and files

[cpp]  view plain copy  
  1. staticvoid DeleteDirectories(CString csPath)   
  2. {     
  3.     CFileFind finder;  
  4.     CString tempPath;  
  5.     tempPath.Format("%s%s", csPath, "//*.*");  
  6.     BOOL bWork = finder.FindFile(tempPath);  
  7.     while(bWork)  
  8.     {         
  9.         bWork = finder.FindNextFile();  
  10.         if(!finder.IsDots())  
  11.         {  
  12.             if(finder.IsDirectory())  
  13.             {  
  14.                 DeleteDirectories(finder.GetFilePath());  
  15.             }  
  16.             else  
  17.             {  
  18.                 DeleteFile(finder.GetFilePath());  
  19.             }  
  20.         }  
  21.     }  
  22.     finder.Close();  
  23.     RemoveDirectory(csPath);  

  1. }  

Quote: https://blog.csdn.net/timothy721/article/details/8860050




Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324742109&siteId=291194637