Delete folder MFC code
-
I want to delete a folder which is have a content. WIN32_FIND_DATA FindFileData; HANDLE hHandle ; int complt; char FileName[100]; strcpy(FileName,""); char rpath[]="C:\\bootfdr"; char Path[]="C:\\bootfdr\\"; SetCurrentDirectory(Path); hHandle=FindFirstFile("*.*",&FindFileData); if(hHandle == INVALID_HANDLE_VALUE) MessageBox("Path NotFound"); else { while(complt) { strcpy(FileName,Path); strcat(FileName,FindFileData.cFileName); DeleteFile(FileName); complt=FindNextFile(hHandle,&FindFileData); } } FindClose(hHandle); if(RemoveDirectory(rpath)) MessageBox("Deleted"); else MessageBox("Sorry i cant"); am use this code but only files inside the folder is deleted.but not the folder is deleted
Arise Awake Stop Not Till ur Goal is Reached.
-
I want to delete a folder which is have a content. WIN32_FIND_DATA FindFileData; HANDLE hHandle ; int complt; char FileName[100]; strcpy(FileName,""); char rpath[]="C:\\bootfdr"; char Path[]="C:\\bootfdr\\"; SetCurrentDirectory(Path); hHandle=FindFirstFile("*.*",&FindFileData); if(hHandle == INVALID_HANDLE_VALUE) MessageBox("Path NotFound"); else { while(complt) { strcpy(FileName,Path); strcat(FileName,FindFileData.cFileName); DeleteFile(FileName); complt=FindNextFile(hHandle,&FindFileData); } } FindClose(hHandle); if(RemoveDirectory(rpath)) MessageBox("Deleted"); else MessageBox("Sorry i cant"); am use this code but only files inside the folder is deleted.but not the folder is deleted
Arise Awake Stop Not Till ur Goal is Reached.
Use of
SHFileOperation
WhiteSky
-
I want to delete a folder which is have a content. WIN32_FIND_DATA FindFileData; HANDLE hHandle ; int complt; char FileName[100]; strcpy(FileName,""); char rpath[]="C:\\bootfdr"; char Path[]="C:\\bootfdr\\"; SetCurrentDirectory(Path); hHandle=FindFirstFile("*.*",&FindFileData); if(hHandle == INVALID_HANDLE_VALUE) MessageBox("Path NotFound"); else { while(complt) { strcpy(FileName,Path); strcat(FileName,FindFileData.cFileName); DeleteFile(FileName); complt=FindNextFile(hHandle,&FindFileData); } } FindClose(hHandle); if(RemoveDirectory(rpath)) MessageBox("Deleted"); else MessageBox("Sorry i cant"); am use this code but only files inside the folder is deleted.but not the folder is deleted
Arise Awake Stop Not Till ur Goal is Reached.
-
I want to delete a folder which is have a content. WIN32_FIND_DATA FindFileData; HANDLE hHandle ; int complt; char FileName[100]; strcpy(FileName,""); char rpath[]="C:\\bootfdr"; char Path[]="C:\\bootfdr\\"; SetCurrentDirectory(Path); hHandle=FindFirstFile("*.*",&FindFileData); if(hHandle == INVALID_HANDLE_VALUE) MessageBox("Path NotFound"); else { while(complt) { strcpy(FileName,Path); strcat(FileName,FindFileData.cFileName); DeleteFile(FileName); complt=FindNextFile(hHandle,&FindFileData); } } FindClose(hHandle); if(RemoveDirectory(rpath)) MessageBox("Deleted"); else MessageBox("Sorry i cant"); am use this code but only files inside the folder is deleted.but not the folder is deleted
Arise Awake Stop Not Till ur Goal is Reached.
Mr. deeps_cute, you've been asking question over this board for long time now... will you once comply to the posting guidelines[^] ??? I especially talk about the
<pre></pre>
tags, but some other points apply to you too
[VisualCalc][Binary Guide][CommDialogs] | [Forums Guidelines]
-
use SHFileOperation instead of RemoveDirectory. This function will delete the directory event if there are contents in that folder.
nave
I like to Delete folder in any case even if other applications or other users are accessing the same folder. Forcefully i like to delete the Folder. I receive Error 32 when the function SHFileOperation(). Can any one tell me how can i acheive this.
-
I like to Delete folder in any case even if other applications or other users are accessing the same folder. Forcefully i like to delete the Folder. I receive Error 32 when the function SHFileOperation(). Can any one tell me how can i acheive this.
yeah. if any process has kept any files opened from that folder. you will not be able to delete it. refer this article Listing Used Files[^]
nave [My Articles] [My Blog]