Good stuff, my original suggestion was to do a recursive procedure. I find them quite satisfying in a perverse sort of way ;-)
All's well that ends well... Cheers, Conor -----Original Message----- From: [EMAIL PROTECTED] [mailto:bigal@;xtra.co.nz] Sent: Tuesday, 12 November 2002 12:11 p.m. To: Multiple recipients of list delphi Subject: [DUG]: Deletefile('D:\*.*'); Hello Conor, After fiddling around with your routine I gave up and ended up with this which works well leaving directory clean of all files and directories thanks anyway.Al+ procedure TForm1.DelTree(dir: string); var Search: TSearchRec; fp: file of byte; ok: integer; begin ok := FindFirst(dir + '\*.*', faAnyFile, Search); while ok = 0 do begin if ((Search.Name <> '.') and (Search.Name <> '..')) then begin if ((Search.Attr and faDirectory) > 0) then begin DelTree(dir + '\' + Search.Name); // sub branch has been searched, so delete it RmDir(dir + '\' + Search.Name); end else begin // do something with the file assignfile(fp, dir + '\' + Search.Name); erase(fp); end; end; ok := FindNext(Search); end; FindClose(Search); end; --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/