Copy Directory in Delphi.
In order to copy the content of a directory to the new location, I used ShFileOperation function. Important: if you want to copy only the content of the folder and not the folder itself, the StrFrom parameter should end with *.* like C:\MyTestFolder\sourceFolder\*.*
function TInstallationController.CopyDirectory(FormHandle : THandle;
StrFrom, StrTo : string;
BlnSilent : Boolean = False) : Boolean;
var
F : TShFileOpStruct;
begin
F.Wnd:=FormHandle;
F.wFunc:=FO_COPY;
F.pFrom:=PChar(StrFrom + #0);
F.pTo:=PChar(StrTo+#0);
F.fFlags := FOF_ALLOWUNDO or FOF_NOCONFIRMATION;
if BlnSilent then
F.fFlags := F.fFlags or FOF_SILENT;
if ShFileOperation(F) 0 then
result:=False
else
result:=True;
end;

Thanks a lot! I found a similar procedure on the net, but what it missed was #0.
author: David L. | February 3rd, 2010 at 3:38 pm