【MFC】VC 删除目录和文件

[cpp]  view plain  copy
  1. static void 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. }  

引用:https://blog.csdn.net/timothy721/article/details/8860050




猜你喜欢

转载自blog.csdn.net/wyq429703159/article/details/80060663
今日推荐