How to delete the Folder and its file using VC++ code

N

nirub

hi
this nirub i want the guideness for deleting the folder and its
files...
here i attached my code deleting file but i cant delete the folder..
if any of one give me idea for that.....

WIN32_FIND_DATA FindFileData;
HANDLE hHandle;
int complt;
char FileName[100];
strcpy(FileName,"");
char rpath[]="C:\\Sam";
char Path[]="C:\\Sam\\";
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);
int d=RemoveDirectory(rpath);
if(d)
MessageBox("Deleted");
else
MessageBox("Sorry i cant");
int i=CreateDirectory(rpath,NULL);
if(i)
MessageBox("Created");
else
MessageBox("Sorry i cant");
 
V

Victor Bazarov

nirub said:
hi
this nirub i want the guideness for deleting the folder and its
files...
here i attached my code deleting file but i cant delete the folder..
if any of one give me idea for that.....

WIN32_FIND_DATA FindFileData;
[...]

Wrong newsgroup. Try 'microsoft.public.*' hierarchy.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top