...rename a directory?

Author: Thomas Stutz

Category: Files

uses
  
ShellApi;

procedure RenameDir(DirFrom, DirTo: string);
var
  
shellinfo: TSHFileOpStruct;
begin
  with 
shellinfo do
  begin
    
Wnd    := 0;
    wFunc  := FO_RENAME;
    pFrom  := PChar(DirFrom);
    pTo    := PChar(DirTo);
    fFlags := FOF_FILESONLY or FOF_ALLOWUNDO or
              
FOF_SILENT or FOF_NOCONFIRMATION;
  end;
  SHFileOperation(shellinfo);
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  
RenameDir('C:\Dir1', 'C:\Dir2');
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base