Name

RmDir Procedure

Syntax

procedure RmDir(const Directory: string);

Description

RmDir removes a directory. If RmDir cannot delete the directory, it reports the Windows error code as an I/O error. In particular, if the directory is not empty, the error code is Error_Dir_Not_Empty (145). RmDir is not a real procedure.

Example

// Delete a directory and its contents.
procedure DestroyDir(const Directory: string);
var
  Path: string;
  Search: TSearchRec;
begin
  Path := IncludeTrailingBackslash(Directory);
  if FindFirst(Path + '*.*', faAnyFile, Search) = 0 then
  try
    repeat
      if (Search.Attr and faDirectory) <> 0 then
        DestroyDir(Path + Search.Name)
      else
        DeleteFile(Path + Search.Name);
    until FindNext(Search) <> 0;
  finally
    FindClose(Search);
  end;
  RmDir(Path);
end;

See Also

ChDir Procedure, GetDir Procedure, IOResult Function, MkDir Procedure
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset