?
Solved

How to delete a bunch of files with wildcards ?

Posted on 1999-01-11
3
Medium Priority
?
445 Views
Last Modified: 2010-04-04
How to delete a bunch of files with wildcards ?
How to delete the directory that contains those file ?
Can I do it with the DeleteFile() function ?

p05010
0
Comment
Question by:p05010
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 0 total points
ID: 1355915
Hi p05010,

You can indeed delete your files with the DeleteFile function and then remove the empty directory with rmDir (with the precursion that the directory is empty)

:O)
Hope this helps
brUINTje.
0
 
LVL 44

Expert Comment

by:bruintje
ID: 1355916
Stupid me.............

Ok a bit sleepy but here is the trick that will do it

procedure TForm1.Button1Click(Sender: TObject);
var
  sr : TSearchRec;
  res: integer;
  thisdir: string;
begin
  thisdir :='c:\arj\dtext23\bitmaps';
  if DirectoryExists(thisdir) then
  try
    SetCurrentDir(Thisdir);
    res := FindFirst('*.*', 0, sr);
    try
      while (res = 0) do
      begin
        if (sr.name <> '.') and (sr.name <> '..') then
        begin
          DeleteFile(sr.name);
        end;
        res := FindNext(sr);
      end;
    finally
      FindClose(sr);
    end;
    SetCurrentDir('c:\arj\dtext23');
    RmDir(ThisDir);
  except on E:Exception do
      showmessage(E.Message);
  end;
end;

put Filectrl in your uses clause for the directoryexists function.

0
 
LVL 1

Author Comment

by:p05010
ID: 1355917
Thx, I will try it.
Looks good a first sight.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month12 days, 9 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question