 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
JoeBlack Guest
|
Posted: Fri May 06, 2005 2:02 pm Post subject: deleting files in a directory |
|
|
Hi all,
I have a function, as follows:
void __fastcall TMainForm::DeleteAllFiles(void)
{
char szb[500];
char szc[500];
SHFILEOPSTRUCT shfo;
shfo.hwnd = GetDesktopWindow();
shfo.wFunc = FO_DELETE;
wsprintf(szb,"%s%c%c",DirList->Strings[HOMENETWORK],0,0);
shfo.pFrom = &szb[0];
wsprintf(szc,"%s%c%c",DirList->Strings[HOMELOCAL],0,0);
shfo.pTo = &szc[0];
shfo.fFlags = FOF_NOCONFIRMATION | FOF_ALLOWUNDO ;
SHFileOperation(&shfo);
}
DirList is a string list with directory names in it, the problem is the line
wsprintf(szb,"%s%c%c",DirList->Strings[HOMENETWORK],0,0);
copies a directory name, say "c:\temp1" into the pFrom string, when I
call the SHFileOperation it deletes the "c:\temp1" directory. What I
would like to do is delete all its contents but leave the directory intact.
I could generate a list of all the files and folders in the directory
and delete them individually but I was wondering if there was an easier
way to do it, i.e. by modifying the code presented above.
Any thoughts
Thanks
Joe
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Fri May 06, 2005 5:39 pm Post subject: Re: deleting files in a directory |
|
|
"JoeBlack" <JoeBlack (AT) newsgroups (DOT) nospam> wrote
| Quote: | the problem is the line
wsprintf(szb,"%s%c%c",DirList->Strings[HOMENETWORK],0,0);
copies a directory name, say "c:\temp1" into the pFrom string,
when I call the SHFileOperation it deletes the "c:\temp1" directory.
What I would like to do is delete all its contents but leave the
directory intact.
|
Have youtried specifying a file mask, ie: "c:\temp\*.*" ? Have you tried
applying the FOF_FILESONLY flag?
Gambit
|
|
| Back to top |
|
 |
JoeBlack Guest
|
Posted: Mon May 09, 2005 8:19 am Post subject: Re: deleting files in a directory |
|
|
Remy Lebeau (TeamB) wrote:
| Quote: | "JoeBlack" <JoeBlack (AT) newsgroups (DOT) nospam> wrote in message
news:427b78e2 (AT) newsgroups (DOT) borland.com...
the problem is the line
wsprintf(szb,"%s%c%c",DirList->Strings[HOMENETWORK],0,0);
copies a directory name, say "c:\temp1" into the pFrom string,
when I call the SHFileOperation it deletes the "c:\temp1" directory.
What I would like to do is delete all its contents but leave the
directory intact.
Have youtried specifying a file mask, ie: "c:\temp\*.*" ? Have you tried
applying the FOF_FILESONLY flag?
Gambit
Remy, |
Many thanks, this has sorted my problem.
Joe
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|