Link to home
Start Free TrialLog in
Avatar of zaibatzuka
zaibatzuka

asked on

D1:Recursiv deletion of directories and content

How can I delete a directory with contents, including subdirectories in Delphi 1.0 (Windows 3.11) ?
Avatar of ZifNab
ZifNab

Let me propose this :
 1. Look for a component which does recursif searching.
     (enough freeware components on the net)
 2. Delete every founded file or directory

Here is already a code for searchin the entire disk. Easely changed in searching through one directory.

unit Audit1;
interface
uses windos;

var
  dest:string;

procedure dorecurse(dir:string);

implementation
{$R *.DFM}
Procedure Process (dir:string; Searchrec:tsearchrec);
begin
   showmessage (Searchrec.name);
   case Searchrec.attr of
   $10:
      if (searchrec.name<>'.') and (searchrec.name<>'..') then
          begin
        dorecurse (dir+'\'+searchrec.name);
                writeln (dir);
          end;
   end;
end;

Procedure Dorecurse(dir:string);
var
   Searchrec:Tsearchrec;
   pc: array[0..79] of Char;
   
begin
   StrPCopy(pc, dir+'\*.*');
   FindFirst(pc, FaAnyfile, SearchRec);
   Process (dir,SearchRec);
   while FindNext(SearchRec)<>-18 do
   begin
      Process (dir,SearchRec);
   end;
end;

Procedure startsearch;
begin
   dorecurse (paramstr(1));
end;

begin
   startsearch;
end.

Have fun,
c.u. ZifNab;
ASKER CERTIFIED SOLUTION
Avatar of aluiken
aluiken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of zaibatzuka

ASKER

OK. Note that the line above Application.ProcessMessages is missing a left braces. Indentations would have made it easier to follow the code.
Thanks.
hey a html memo is sumthing else then the borland delphi UI
=)