Board index » delphi » Removing a directory and all sub-directories and files

Removing a directory and all sub-directories and files

Is there any function to remove a directory totally, even if there is
files and other sub-directories under it??

Please help!!
Bennie Haasbroek

  vcard.vcf
< 1K Download
 

Re:Removing a directory and all sub-directories and files


Quote
Benny Haasbroek wrote:

> Is there any function to remove a directory totally, even if there is
> files and other sub-directories under it??

You could do it with something like this I think:

procedure DeleteIt(TheDirectory: String);
VAR
  SFO: TSHFILEOPSTRUCT;
  X: Integer;
begin
  SFO.wFunc:=FO_DELETE;
  SFO.pFrom:=PChar(TheDirectory+#0+#0);
  SFO.fFlags:=FOF_SIMPLEPROGRESS+FOF_ALLOWUNDO;
  X:=ShFileOperation(SFO);
  if X<>0 then
    ShowMessage('Error Deleting '+TheDirectory+#13+'Exit code was
'+IntToStr(X));
end;

NOTE I did not test this so tread with care.

Re:Removing a directory and all sub-directories and files


Benny Haasbroek schrieb in Nachricht <351136E1.74111...@csir.co.za>...

Quote
>Is there any function to remove a directory totally, even if there is
>files and other sub-directories under it??

>Please help!!
>Bennie Haasbroek

SHFileOperation could be useful to you. You'll also get all the bells
and whistles of Win95, if you want to.
See win32.hlp in the [Delphi]\Help directory.

Groeten uit Duitsland
--
Rudy Velthuis

Other Threads