🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12604

Searching for an deleting files

#12604
From: Greg Stantin
Date: Sun, 30 Nov 2003 04:50
38 lines
2025 bytes
Can someone tell me if i am missing something in this code,
i am basically searching for a specific file mask then deleting
it when i find it.  Exactly where do i put the code to delete the
file when i find it?

DeleteFilesInDirectory("C:\\temp\\", "*.old");


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
        {
            // Here we skip files that don't meet the attributes
selected
            // on the screen.
            if((Data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0
                && String(Data.cFileName) != "." &&
String(Data.cFileName) != "..")
            {
                DeleteFilesInDirectory(Directory + Data.cFileName +
"\\", Mask);
            }
        }

        while(FindNextFile(hFile, &Data));
        FindClose(hFile);
    }
}
//--------------------------------------------------------------------
-------


Thanks.......
Technical Details
Message-ID: <3fc97723@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-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,de74c80c594dbf57,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-11-29 21:09:05 PST
Reply-To: "Greg Stantin" <gstantin@stantonassoc.com>
From: "Greg Stantin" <gstantin@stantonassoc.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Searching for an deleting files
Date: Sat, 29 Nov 2003 22:50:46 -0600
Lines: 40
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: <3fc97723@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1070167843 216.62.159.110 (29 Nov 2003 20:50:43 -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