文件的copy/Move

liufh520 2002-12-17 10:52:35
现在我已知一文件的目录(string型)
如何将它copy/move到一个指定的目录下(文件名相同)请给我一个范例程式源码.
...全文
67 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
liufh520 2002-12-17
  • 打赏
  • 举报
回复
chaosbird(canan):
可是MoveFile里面的参数是Pchar类型的
Billy_Chen28 2002-12-17
  • 打赏
  • 举报
回复
copy只是改参数了
Billy_Chen28 2002-12-17
  • 打赏
  • 举报
回复
procedure TForm1.moveClick(Sender: TObject);
//移动c:\sybase目录下所有文件到d:\sybase目录下
var
sourcefile,destinationfile:STRING;
lpfileop:TSHFILEOPSTRUCT;
begin
sourcefile:= 'c:\sybase\*.*'+#0#0;
destinationfile:= 'd:\sybase'+#0#0;
fillchar(lpfileop,sizeof(lpfileop),0);
with lpfileop do
begin
wnd:=form1.handle;
wFunc:=FO_MOVE;
pFrom:=pchar(sourcefile);
pTo:=pchar(destinationfile);
fflags:= FOF_NOCONFIRMATION or FOF_NOCONFIRMMKDIR;
end;
if SHFileOperation(lpfileop)<>NOERROR then
if lpfileop. FAnyOperationsAborted then
showmessage('移动文件被终止')
else
showmessage('移动文件出错');

end;
chaosbird 2002-12-17
  • 打赏
  • 举报
回复
BOOL MoveFile(

LPCTSTR lpExistingFileName, // address of name of the existing file
LPCTSTR lpNewFileName // address of new name for the file
);

BOOL CopyFile(

LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧