Apr 5, 2002 #1 Robertus Programmer Feb 16, 2001 81 RO Does anybody know how could I delete all subfolders and files of a given folder (with MFC)? I would apreciate your help, thanks a lot!
Does anybody know how could I delete all subfolders and files of a given folder (with MFC)? I would apreciate your help, thanks a lot!
Apr 5, 2002 #2 LiquidBinary Programmer Jul 27, 2001 148 US #define WIN32_LEAN_AND_MEAN #include <windows.h> #include <shellapi.h> #include <iostream> int DeleteFolderStruct( LPSTR lpzRoot ) { SHFILEOPSTRUCT shellOp; shellOp.hwnd =NULL; shellOp.wFunc =FO_DELETE; shellOp.pFrom =lpzRoot; shellOp.pTo =NULL; shellOp.fFlags=FOF_NOCONFIRMATION | FOF_SILENT; shellOp.hNameMappings=0; shellOp.lpszProgressTitle=NULL; return SHFileOperation( &shellOp ); } int main() { char* sDir="C:\\deleteTemp"; if( DeleteFolderStruct( sDir )==0 ) std::cout << sDir << " was deleted." << std::endl; else std::cout << sDir << " COULD NOT BE DELETED." << std::endl; return 0; } It should be trivial to integrate this into an MFC app. Mike L.G. mlg400@linuxmail.org Upvote 0 Downvote
#define WIN32_LEAN_AND_MEAN #include <windows.h> #include <shellapi.h> #include <iostream> int DeleteFolderStruct( LPSTR lpzRoot ) { SHFILEOPSTRUCT shellOp; shellOp.hwnd =NULL; shellOp.wFunc =FO_DELETE; shellOp.pFrom =lpzRoot; shellOp.pTo =NULL; shellOp.fFlags=FOF_NOCONFIRMATION | FOF_SILENT; shellOp.hNameMappings=0; shellOp.lpszProgressTitle=NULL; return SHFileOperation( &shellOp ); } int main() { char* sDir="C:\\deleteTemp"; if( DeleteFolderStruct( sDir )==0 ) std::cout << sDir << " was deleted." << std::endl; else std::cout << sDir << " COULD NOT BE DELETED." << std::endl; return 0; } It should be trivial to integrate this into an MFC app. Mike L.G. mlg400@linuxmail.org