delete directory
-
how to delete a directory which has sub-directories and files directly? thanks includeh10
-
how to delete a directory which has sub-directories and files directly? thanks includeh10
Hi, See this article in CP.. http://www.codeproject.com/file/removefiles.asp all the best:rose: anju
-
Hi, See this article in CP.. http://www.codeproject.com/file/removefiles.asp all the best:rose: anju
it is still to delete files first in a loop ... :rose: includeh10
-
how to delete a directory which has sub-directories and files directly? thanks includeh10
-
how to delete a directory which has sub-directories and files directly? thanks includeh10
::SHFileOperation()
Rickard Andersson@Suza Computing C# and C++ programmer from SWEDEN! UIN: 50302279 E-Mail: nikado@pc.nu Speciality: I love C#, ASP.NET and C++! -
how to delete a directory which has sub-directories and files directly? thanks includeh10
BOOL ClearDirectory(const char *path, BOOL recurs, BOOL deldirs) { if(!path) return FALSE; char xpath[512]=""; strcpy(xpath,path); HANDLE hFile; WIN32_FIND_DATA findData; BOOL Go=TRUE; char fullp[500]=""; char pattern[500]=""; if(xpath[strlen(xpath)-1]!='\\') strcat(xpath,"\\"); if(!IsDirectory(xpath)) return FALSE; strcpy(pattern,xpath); strcat(pattern,"*.*"); hFile=FindFirstFile(pattern,&findData); while((hFile!=INVALID_HANDLE_VALUE)&&(Go)) { if((strcmp(findData.cFileName,".")!=0)&&(strcmp(findData.cFileName,"..")!=0)) { strcpy(fullp,""); sprintf(fullp,"%s%s",xpath,findData.cFileName); if(IsDirectory(fullp)) { ClearDirectory(fullp,recurs,deldirs); strcat(fullp,"\\"); if(deldirs) RemoveDirectory(fullp); } else { SetFileAttributes(fullp,128); DeleteFile(fullp); } } ZeroMemory((void*)&findData,sizeof(findData)); Go=FindNextFile(hFile,&findData); } FindClose(hFile); if(deldirs) RemoveDirectory(xpath); return TRUE; } be nice an rate me ! be cool I am the mighty keeper of the book on knowledge . Contact me to get your copy .