想复制文件到某目录下,
存在文件则覆盖
我该用哪些函数呢??
望大虾指点下
存在文件则覆盖
我该用哪些函数呢??
望大虾指点下
解决方案 »
- 用OpenGL做了一个程序,想加入MFC的对话框,为什么说'IDD_ABOUT' : undeclared identifier?
- 关于游戏里面的AI
- listctrl 里有 右击表头响应函数吗?(在线等)
- 在客户区的问题
- 请教
- 要在系统资源管理器左边嵌入自已的界面,如何做,高手请进??
- 求助!关于图象旋转问题
- 毫秒级数据采集并实时显示,为何有这样大的问题啊?
- 一个程序爱好者,大三,非计算机专业,对将来从事软件开发感到迷茫,望作为过来人的兄弟指点迷津!!!回者将另贴加分
- 如何实现象VC的Output窗口那样的视图?
- 在menu上实现一个dialog,如何初始化这个dialog
- VC绘图的小问题,进来看详细
LPCTSTR lpExistingFileName,
LPCTSTR lpNewFileName,
BOOL bFailIfExists
);
bFailIfExists
[in] If this parameter is TRUE and the new file specified by lpNewFileName already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.
BOOL CommonCopyFile(CString SourceFileName, CString DestFileName)
{
CFile sourceFile ;
CFile destFile ;
CFileException ex;
if (!sourceFile.Open((LPCTSTR)SourceFileName,CFile::modeRead | CFile::shareDenyWrite, &ex))
{
TCHAR szError[1024];
ex.GetErrorMessage(szError, 1024);
CString ErrorMsg = "打开文件:" ;
ErrorMsg += SourceFileName ;
ErrorMsg += "失败。\n错误信息为:\n" ;
ErrorMsg += szError ;
AfxMessageBox(ErrorMsg);
return FALSE ;
}
else
{
if (!destFile.Open((LPCTSTR)DestFileName, CFile::modeWrite | CFile::shareExclusive | CFile::modeCreate, &ex))
{
TCHAR szError[1024];
ex.GetErrorMessage(szError, 1024);
CString ErrorMsg = "创建文件:" ;
ErrorMsg += DestFileName ;
ErrorMsg += "失败。\n错误信息为:\n" ;
ErrorMsg += szError ;
AfxMessageBox(ErrorMsg);
sourceFile.Close();
return FALSE ;
} BYTE buffer[4096];
DWORD dwRead;
do
{
dwRead = sourceFile.Read(buffer, 4096);
destFile.Write(buffer, dwRead);
}
while (dwRead > 0);
destFile.Close();
sourceFile.Close();
}
return TRUE ;
}