Mirror

How to copy folders from one drive to another (Views: 100)


Problem/Question/Abstract:

How to copy folders from one drive to another

Answer:

uses
  ShellAPI;

procedure CopyTree(dir, dest: string);
var
  sfos: TSHFileOpStruct;
begin
  FillChar(sfos, SizeOf(sfos), 0);
  dir := dir + '\*.*'#0;
  dest := dest + '\*.*'#0;
  with sfos do
  begin
    wnd := 0;
    wfunc := FO_COPY;
    pFrom := PChar(dir);
    pTo := PChar(dest);
    fFlags := FOF_ALLOWUNDO or FOF_RENAMEONCOLLISION or FOF_SIMPLEPROGRESS;
    fAnyOperationsAborted := false;
    hNameMappings := nil;
    lpszProgressTitle := nil
  end;
  SHFileOperation(sfos);
end;

<< Back to main page