有谁知道Delphi中有没有复制文件的函数呀(急),在线等待。(100分)

  • 主题发起人 主题发起人 780626
  • 开始时间 开始时间
7

780626

Unregistered / Unconfirmed
GUEST, unregistred user!
有谁知道Delphi中有没有复制文件的函数呀,或是怎么样实现文件的复制呀?
 
复制文件。<br>&nbsp; &nbsp; procedure TForm1.Button1Click(Sender: TObject);<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; try<br>&nbsp; &nbsp; &nbsp; copyfileA(pchar('C:/AAA.txt'),pchar('D:/AAA.txt'),false);<br>&nbsp; &nbsp; &nbsp; except<br>&nbsp; &nbsp; &nbsp; showmessage('sfdsdf');<br>&nbsp; &nbsp; &nbsp; end;<br>&nbsp; &nbsp; end;<br>复制文件夹。<br>&nbsp; &nbsp; uses shellAPI;<br>&nbsp; &nbsp; procedure TForm1.Button1Click(Sender: TObject);<br>&nbsp; &nbsp; var<br>&nbsp; &nbsp; &nbsp; &nbsp;lpFileOp: TSHFileOpStruct;<br>&nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; with lpFileOp do<br>&nbsp; &nbsp; &nbsp; begin<br>&nbsp; &nbsp; &nbsp; &nbsp; Wnd:=Self.Handle;<br>&nbsp; &nbsp; &nbsp; &nbsp; wfunc:=FO_COPY;<br>&nbsp; &nbsp; &nbsp; &nbsp; pFrom:=pchar('C:/AAA');<br>&nbsp; &nbsp; &nbsp; &nbsp; pTo:=pchar('D:/AAA');<br>&nbsp; &nbsp; &nbsp; &nbsp; fFlags:=FOF_ALLOWUNDO;<br>&nbsp; &nbsp; &nbsp; &nbsp; hNameMappings:=nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; lpszProgressTitle:=nil;<br>&nbsp; &nbsp; &nbsp; &nbsp; fAnyOperationsAborted:=True;<br>&nbsp; &nbsp; &nbsp;end;<br>&nbsp; &nbsp; &nbsp;if SHFileOperation(lpFileOp)&lt;&gt;0 then<br>&nbsp; &nbsp; &nbsp;ShowMessage('删除失败');<br>&nbsp; &nbsp; end;
 
copyfileA(pchar('C:/AAA.txt'),pchar('D:/AAA.txt'),false);//如为true,为如已有复盖
 
TO :dandanw<br><br>copyfileA(pchar('C:/AAA.txt'),pchar('D:/AAA.txt'),false);<br>最后一个参数 是什么作用?<br>
 
CopyFileTo(SrcFile,DestFile);
 
多人接受答案了。
 
最后参数如为true,则如目标已有此文件,复盖。为false,不盖
 
后退
顶部