delphi7如何复制目录

来源:百度知道 编辑:UC知道 时间:2024/06/23 19:52:59
RT。最好有源码

procedure CheckDirectorySuffix(var ADirPath : string);
begin
if Copy(ADirPath, Length(ADirPath), 1) <> '\' then
ADirPath:= ADirPath + '\'
else
ADirPath:= ADirPath;
end;

procedure CopyDirectory(const ARootDirFrom, ARootDirTo : string);
var
rootDirFrom : string;
rootDirTo : string;
fileName : TFileName;
oSearchRec : TSearchRec;
dirPathList : TStringList;
nDirIndex:integer;
begin
rootDirFrom := Trim(ARootDirFrom);
rootDirTo := Trim(ARootDirTo);
if (rootDirFrom <> '') and (rootDirTo <> '') then
begin
//判断目标目录中是否存在此对应的目录,如果没有则生成此目录
if not DirectoryExists(rootDirTo) then
CreateDir(rootDirTo);

CheckDirectorySuffix(rootDirFrom);
CheckDirectorySuffix(rootDirTo);

dirPathList := TStringList.Create;

if FindFirst(rootDirFrom+ '