Solved

How to delete a bunch of files with wildcards ?

Posted on 1999-01-11
3
439 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
  • 2
3 Comments
 
LVL 44

Accepted Solution

by:
bruintje earned 0 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Thx, I will try it.
Looks good a first sight.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Display a PDF file and get words from it 6 96
proper way to parse text with delphi 7 87
find a node in VST 2 46
Working with hours 3 31
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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now