bool copyDirAndFile(QFileInfo file, QString path)
{
if (file.isDir()){
QDir dir (file.filePath());
foreach(auto fileName, dir.entryInfoList(QDir::NoDotAndDotDot | QDir::AllEntries))
copyDirAndFile (fileName, path + dir.dirName () + "/");
}
QFile temp;
QDir dir(path);
if(!dir.exists())
dir.mkpath (path);
temp.copy(file.absoluteFilePath(), path + file.fileName());
temp.close();
return true;
}
//将d盘的var文件复制到c盘 copyDirAndFile(QString("D:/var"), QString("C:/"));