How do I copy a file from one folder to another folder using C++?
See Question&Answers more detail:osHow do I copy a file from one folder to another folder using C++?
See Question&Answers more detail:osThis should be the minimal code required:
#include <fstream>
// copy in binary mode
bool copyFile(const char *SRC, const char* DEST)
{
std::ifstream src(SRC, std::ios::binary);
std::ofstream dest(DEST, std::ios::binary);
dest << src.rdbuf();
return src && dest;
}
int main(int argc, char *argv[])
{
return copyFile(argv[1], argv[2]) ? 0 : 1;
}
it glosses around some potentially complicated issues: error handling, filename character encodings... but could give you a start.