📄 fileop.cpp
字号:
// FileOP.cpp: implementation of the CFileOP class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "FileExample.h"
#include "FileOP.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CFileOP::CFileOP()
{
}
CFileOP::~CFileOP()
{
}
BOOL CFileOP::Copy(CString strSourcePath, CString strTargetPath)
{
CFile fSource, fTarget;
//定义4k字节的缓冲区
char c[4096];
int nCount;
//打开文件
if (!fSource.Open(strSourcePath, CFile::modeRead))
{
AfxMessageBox("Open Source File Fail!");
return false;
}
if (!fTarget.Open(strTargetPath, CFile::modeCreate | CFile::modeWrite))
{
AfxMessageBox("Create Target File Fail!");
return false;
}
//读文件到缓冲区c
nCount = fSource.Read(c, 4096);
while (nCount)
{
fTarget.Write(c, nCount);
nCount = fSource.Read(c, 4096);
}
fSource.Close();
fTarget.Close();
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -