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