...use the shell function to copy/move a file?

Author: Simon Grossenbacher
Homepage: http://www.swissdelphicenter.ch

Category: Files

uses
  
ShellApi;

procedure ShellFileOperation(fromFile: string; toFile: string; Flags: Integer);
var
  
shellinfo: TSHFileOpStructA;
begin
  with 
shellinfo do
  begin
    
wnd   := Application.Handle;
    wFunc := Flags;
    pFrom := PChar(fromFile);
    pTo   := PChar(toFile);
  end;
  SHFileOperation(shellinfo);
end;


// Example, Beispiel:

procedure TForm1.Button1Click(Sender: TObject);
begin
  
ShellFileOperation('c:\afile.txt', 'd:\afile2.txt', FO_COPY);
  // To Move a file: FO_MOVE
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base