1.先包含头文件#include <Windows.h>
2.函数CopyFile的原型如下
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
);
用法
CopyFile("e:\\abb.txt","d:\\zhengyong.txt",FALSE);即可。
第三个参数有以下说明:
如果设为TRUE(非零),那么一旦目标文件已经存在,则函数调用会失败。否则目标文件会被覆盖掉。
3.如果传入的第二个和第三个参数的类型为string类型,会报错,解决办法参考: