Mega Code Archive

 
Categories / Delphi / Files
 

Copy or move a file

Title: Copy or move a file Question: How can I copy or move a specified file to an other location? Answer: uses ShellAPI; function FileCopy(Source, Destination: string): boolean; var ShFileOpStruct: TShFileOpStruct; begin with ShFileOpStruct do begin { operation; FO_MOVE to move the file } wFunc := FO_COPY; { set source filename } pFrom := PChar(Source); { set destination filename } pTo := PChar(Destination); end; { returns true if successful; otherwise false } result := (0 = SHFileOperation(ShFileOpStruct)); end;