Article View: borland.public.cppbuilder.nativeapi
Article #6432deleting files in a directory
From: JoeBlack
Date: Fri, 06 May 2005 14:02
Date: Fri, 06 May 2005 14:02
37 lines
2026 bytes
2026 bytes
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
Technical Details
Message-ID:
<427b78e2@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,ecd37b850bb40019,start X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Date: Fri, 06 May 2005 15:02:14 +0100 From: JoeBlack <JoeBlack@newsgroups.nospam> User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: borland.public.cppbuilder.nativeapi Subject: deleting files in a directory Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 80.177.44.179 Message-ID: <427b78e2@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1115388130 80.177.44.179 (6 May 2005 07:02:10 -0700) Lines: 37 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail