Article View: borland.public.cppbuilder.nativeapi
Article #12606Re: Searching for an deleting files
From: Greg Stantin
Date: Sun, 30 Nov 2003 05:28
Date: Sun, 30 Nov 2003 05:28
36 lines
2145 bytes
2145 bytes
> In the place where you are testing the file attributes. If the
attributes
> do not represent a directory, then delete the filename. For
example:
Thanks for that, i seem to have run into a snafu now, it won't parse
into sub-directories. I guess i am missing something still.
void TForm1::DeleteFilesInDirectory(String Directory, String Mask)
{
WIN32_FIND_DATA Data;
HANDLE hFile = FindFirstFile((Directory + Mask).c_str(), &Data);
if(hFile != INVALID_HANDLE_VALUE)
{
do
{
String sName(Data.cFileName);
if((sName != ".") && (sName != ".."))
{
if((Data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
!= 0)
DeleteFilesInDirectory(Directory + sName + "\\",
Mask);
else
//DeleteFile(Directory + sName);
ListBox1->Items->Add(Directory + sName);
}
}
while(FindNextFile(hFile, &Data));
FindClose(hFile);
}
}
//--------------------------------------------------------------------
-------
Technical Details
Message-ID:
<3fc98016@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3fc97723@newsgroups.borland.com> <3fc97c1a@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,de74c80c594dbf57 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-11-29 21:38:53 PST Reply-To: "Greg Stantin" <gstantin@stantonassoc.com> From: "Greg Stantin" <gstantin@stantonassoc.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3fc97723@newsgroups.borland.com> <3fc97c1a@newsgroups.borland.com> Subject: Re: Searching for an deleting files Date: Sat, 29 Nov 2003 23:28:57 -0600 Lines: 38 Organization: Stantin Assoc. X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 216.62.159.110 Message-ID: <3fc98016@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1070170134 216.62.159.110 (29 Nov 2003 21:28:54 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail