Copy a copy of the VC ++ folder

I want to copy a directory from one drive to another drive. My selected directory contains many subdirectories and files. How can I implement the same with vC ++

+4
source share
3 answers

The SHFileOperation () function is a workhorse function for copying files. It supports recursive directories. View the options available in the SHFILEOPSTRUCT structure to manage the copy.

+5
source

Hard way. copy each file individually.

Use FindFirst() and FindNext() to iterate over the contents of a directory Use SetCurrentDirectory() to enter and exit directories
Use CreateDirectory() to create a new folder tree
and finally use CopyFile() to copy the actual files

0
source

If you have access to boost library, this is your friend:

http://www.boost.org/doc/libs/1_42_0/libs/filesystem/doc/index.htm

Check out the tutorial for nice examples using the file system iterator.

To get started:

 #include <iostream> #include "boost/filesystem.hpp" int main(int argc, char *argv[]) { boost::filesystem::path path1("/usr/local/include"); // your source path boost::filesystem::path::iterator pathI = path1.begin(); while (pathI != path1.end()) { std::cout << *pathI << std::endl; // here you could copy the file or create a directory ++pathI; } return 0; } 
-1
source

Source: https://habr.com/ru/post/1305427/


All Articles