头文件
#ifndef ioshelperH
#define ioshelperH

#include <fstream>
#include <vcl.h>
//---------------------------------------------------------------------------

class IOHelper
{
public:
void CopyFiles(char* srcPath, char* destPath);
};
#endif
======================================================
源码
void IOHelper::CopyFiles(char* srcPath, char* destPath)
{
//using namespace std;
ifstream src(srcPath, ios::binary | ios::in);
if (src.fail()) {
  //"file src does not exist"
  return;
}
ofstream dest(destPath, ios::out | ios::binary | ios::app);

char buffer[32767];

//获取文件大小
//int filesize;
//src.seekg(ios::beg, ios::end);
//filesize = src.tellg();

src.seekg(ios::beg);
dest.seekp(0);

while (src.good())
{
  memset(buffer, 0, sizeof(char) * 32767);
  src.read(buffer, 32767);

  dest.write(buffer, src.gcount());

  if (src.gcount() < 32767)
            break;
}
}

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-06-28
  • 2021-12-11
  • 2022-12-23
  • 2021-06-17
  • 2021-04-17
  • 2022-01-13
猜你喜欢
  • 2021-08-27
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2021-08-17
  • 2021-05-22
相关资源
相似解决方案