你用的是DELPHI吧
在MSDN里CopyFile的声明如下:
The CopyFile function copies an existing file to a new 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
);
Parameters
lpExistingFileName
Pointer to a null-terminated string that specifies the name of an existing file.
lpNewFileName
Pointer to a null-terminated string that specifies the name of the new file.
bFailIfExists
Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds. 你试试能不能用强制类型转换
在MSDN里CopyFile的声明如下:
The CopyFile function copies an existing file to a new 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
);
Parameters
lpExistingFileName
Pointer to a null-terminated string that specifies the name of an existing file.
lpNewFileName
Pointer to a null-terminated string that specifies the name of the new file.
bFailIfExists
Specifies how this operation is to proceed if a file of the same name as that specified by lpNewFileName already exists. If this parameter is TRUE and the new file already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds. 你试试能不能用强制类型转换
copyfile(PChar(edit1.text),PChar(savedialog1.FileName),false)
procedure TFmWin.mSys_BackClick(Sender: TObject);
begin
if CopyFile(PChar(AppPath+'MjFour.mdb'), 'C:\MjFour.mdb', True) then
FnMsg('数据库(MjFour.mdb)已成功地备份到C:盘的根目录.', 1)
else if FnMsg('数据库备份失败. 可能是C:盘已有先前的备份, 要覆盖它吗?', 2) then
CopyFile(PChar(AppPath+'MjFour.mdb'), 'C:\MjFour.mdb', False);
end;