M
moonwang
Unregistered / Unconfirmed
GUEST, unregistred user!
Function Copydirectory(Source:string;pDirectory:string;pFilter:string):boolean;
//目录拷贝source :源目录 directory:目标目录 pFilter:文件类型筛选'/*.*'或'/*.???'
var
OpStruc: TSHFileOpStruct;
frombuf, tobuf: Array [0..128] of Char;
begin
FillChar( frombuf, Sizeof(frombuf), 0 );
FillChar( tobuf, Sizeof(tobuf), 0 );
StrPCopy(frombuf, Source+pFilter);
StrPCopy( tobuf, pdirectory);
if not directoryexists(pdirectory) then
if not createdir(pdirectory) then
begin
showmessage('不能创建目录'+pdirectory+chr(13)+chr(10)+'或无该目录权限');
exit;
end;
With OpStruc do
begin
Wnd:= 0;
wFunc:= FO_Copy;
pFrom:= @frombuf;
pTo:=@tobuf;
fFlags:= FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION or FOF_SILENT ;
//or fof_filesonly
fAnyOperationsAborted:= false;
hNameMappings:= Nil;
lpszProgressTitle:= Nil;
end;
try
ShFileOperation(OpStruc );
CopyDirectory:=true;
except
CopyDirectory:=false;
exit;
end;
end;
//目录拷贝source :源目录 directory:目标目录 pFilter:文件类型筛选'/*.*'或'/*.???'
var
OpStruc: TSHFileOpStruct;
frombuf, tobuf: Array [0..128] of Char;
begin
FillChar( frombuf, Sizeof(frombuf), 0 );
FillChar( tobuf, Sizeof(tobuf), 0 );
StrPCopy(frombuf, Source+pFilter);
StrPCopy( tobuf, pdirectory);
if not directoryexists(pdirectory) then
if not createdir(pdirectory) then
begin
showmessage('不能创建目录'+pdirectory+chr(13)+chr(10)+'或无该目录权限');
exit;
end;
With OpStruc do
begin
Wnd:= 0;
wFunc:= FO_Copy;
pFrom:= @frombuf;
pTo:=@tobuf;
fFlags:= FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION or FOF_SILENT ;
//or fof_filesonly
fAnyOperationsAborted:= false;
hNameMappings:= Nil;
lpszProgressTitle:= Nil;
end;
try
ShFileOperation(OpStruc );
CopyDirectory:=true;
except
CopyDirectory:=false;
exit;
end;
end;