Just noticed: there's another bug you should be aware of.
You're checking for '.' and '..' in the wrong place, ie. when the file is
_not_ a directory. Don't run your program as it is or it might try and
erase your whole hard drive...
[Deja vu huh guys? :)]
Cheers,
Carl
-----Original Message-----
From: gajo [mailto:[EMAIL PROTECTED]]
Sent: Sunday, 22 January 1995 0:30
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Delete *.*
My date is set on 1995 so that I would use a shareware program that has
expired..
OK, I wrote down the code like this, but it doesn't work. Where's the
problem?
procedure TForm1.DelDir(Dirname: string);
var
F: TSearchRec;
ftd: Integer;
begin
ftd := FindFirst(Dirname,faAnyFile,F);
while not ftd = 0 do begin // while there is a file do the following
if F.Attr = (faAnyFile - faDirectory) then begin // if file's not a
directory
if F.Name = '.' then else
if F.Name = '..' then else
DeleteFile(F.Name); // then delete it
end;
if F.Attr = faDirectory then begin // if it's a directory
GetDir(0,F.Name); // then change to it
DelDir(Dirname+'\'+F.Name); // use my DelDir on that dir
end;
ftd := FindNext(F); // FindNext
end;
FindClose(F); // the end
end;
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz