function FullDirectoryCopy(SourceDir, TargetDir: string; StopIfNotAllCopied,OverWriteFiles: Boolean): Boolean; var SR: TSearchRec; I: Integer; begin Result := False; SourceDir := IncludeTrailingBackslash(SourceDir); TargetDir := IncludeTrailingBackslash(TargetDir); if not DirectoryExists(SourceDir) then Exit; if not ForceDirectories(TargetDir) then Exit; I := FindFirst(SourceDir + '*', faAnyFile, SR); try while I = 0 do begin if (SR.Name <> '') and (SR.Name <> '.') and (SR.Name <> '..') then begin if SR.Attr = faDirectory then Result := FullDirectoryCopy(SourceDir + SR.Name, TargetDir + SR.NAME,StopIfNotAllCopied, OverWriteFiles) else if not (not OverWriteFiles and FileExists(TargetDir + SR.Name)) then Result := CopyFile(Pchar(SourceDir + SR.Name), Pchar(TargetDir + SR.Name), False) else Result := True; if not Result and StopIfNotAllCopied then exit; end; I := FindNext(SR); end; finally SysUtils.FindClose(SR); end; end;