BOOL CopyFile( LPCTSTR lpExistingFileName, // name of an existing file LPCTSTR lpNewFileName, // name of new file BOOL bFailIfExists // operation if file exists ); bFailIfExists [in]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.如把C:\1\2.TXT ,拷到D:\1 下,代码: SetCurrentDirectory("c:\\1\\"); CopyFile("2.txt","d:\\1\2.txt",false);
LPCTSTR lpExistingFileName, // name of an existing file
LPCTSTR lpNewFileName, // name of new file
BOOL bFailIfExists // operation if file exists
);
bFailIfExists [in]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.如把C:\1\2.TXT ,拷到D:\1 下,代码:
SetCurrentDirectory("c:\\1\\");
CopyFile("2.txt","d:\\1\2.txt",false);
其中第三个参数为TRUE时,如果目的文件已存在,那么函数返回FALSE;
第三个参数为FALSE时,如果目的文件名已存在,那么函数将覆盖目的文件返回TRUE;