这段函数,OK!呵呵,我的Tempory Files目录接近1G了,我可没有仔细实验,只是复制了20多M,都是正确的。<br>全部复制。<br><br>uses shellapi,FileCtrl;<br><br>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><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<br> begin Wnd := 0;<br> wFunc := FO_Copy;<br> pFrom := @frombuf;<br> pTo := @tobuf;<br> fFlags := FOF_NOCONFIRMATION or FOF_RENAMEONCOLLISION or FOF_SILENT;<br> //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>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>Copydirectory('C:/Windows/Tempor~1','F:/aa','/*.*');<br>end;<br>