我想将目录从一个驱动器复制到另一个驱动器。我选择的目录包含许多子目录和文件。我如何使用 vc++ 实现相同的功能
问问题
3353 次
3 回答
5
SHFileOperation() API 函数是复制文件的主力函数。它支持递归目录。查看SHFILEOPSTRUCT结构中可用的选项以控制复制。
于 2010-03-29T07:49:31.537 回答
0
艰难的路。单独复制每个文件。
使用FindFirst()
andFindNext()
遍历目录的内容 使用SetCurrentDirectory()
进出目录
使用CreateDirectory()
创建新的文件夹树
,最后,使用CopyFile()
复制实际文件
于 2010-03-29T07:46:58.247 回答
-1
如果您有权访问 boost 库,这是您的朋友:
http://www.boost.org/doc/libs/1_42_0/libs/filesystem/doc/index.htm
查看教程以获取使用文件系统迭代器的好示例。
为了让你开始:
#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;
}
于 2010-03-29T07:48:30.143 回答