void copyFile(CString file1,CString file2)
{
CFile hFile;
int len;
hFile.Open(file1, CFile::modeRead | CFile::typeBinary, 0);
len = hFile.GetLength();
//分配缓冲区
char* buf;
buf = new char[len + 1];
hFile.Read(buf, len); //读文件
hFile.Close();
//只写|二进制|创建的方式打开第二个文件
hFile.Open(file2, CFile::modeWrite | CFile::typeBinary | CFile::modeCreate, 0);
hFile.Write(buf, len);
hFile.Close();
delete[] buf;
}
C++ 文件复制
最新推荐文章于 2024-08-21 18:40:33 发布