怎么在程序中进行文件的Copy?(10分)

  • 主题发起人 主题发起人 ksaiy
  • 开始时间 开始时间
K

ksaiy

Unregistered / Unconfirmed
GUEST, unregistred user!
在程序指定一个源文件和一个目的文件,怎么实现从源文件COPY到目的文件
 
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
);
uses shellapi;
CopyFile('oldfile','newfile',true);
 
delphi帮助

function CopyFileTo(const Source: string; const Destination: string): Boolean;

Parameters

const Source: string

Source file name.


const Destination: string

Destination file name.


Returns

Boolean - True if the file is copied, False on error.


Description

CopyFileTo is a function used to copy the file specified in Source to the file specified in Destination.
CopyFileTo will return False if the file in Destination already exists.
CopyFileTo encapsulates the platform-specific calls needed to perform the file copy operation. On the Windows platform, this is the Win32 API function CopyFile. On the Linux platform, CopyFileTo uses a TFileStream instance to create the destination file.
 
多人接受答案了。
 
T:TSHFileOpStruct;
...
...
With T do
Begin
Wnd:=0;
wFunc:=FO_COPY;
pFrom:=
pTo:=
fFlags:=FOF_ALLOWUNDO+FOF_NOCONFIRMATION+FOF_NOERRORUI;//标志表明允许恢复,无须确认并不显示出错信息
hNameMappings:=nil;
fAnyOperationsAborted:=False;
End;
SHFileOperation(T);
 
后退
顶部