How to use C++ to Copy A Directory
c++, copy, directory, file, windows
Solution
As of today, C++17's `<filesystem>` is the proper solution.
#include <filesystem>
int main()
{
std::filesystem::copy("C:/Users/", "E:/Backup/");
}
The slashes (`/`) are interpreted as directory separators, this is easier to read than a double back-slash (`\\`).
Problem
I have made a backup program using c++, but it uses the System() command to batch copy files. I am looking for a way to copy an entire directory (this does not need to create any directories, just copy them). Or alternatively, copy everything within a directory. For example, I want to copy `C:\Users\ to E:\Backup\ Or C:\Users\* to E:\Backup\`. If possible could you include an example in your answer. Thanks a lot!