void CopyFolder(AnsiString srcPath, AnsiString aimPath)
{
TSearchRec sr;
if (!DirectoryExists(srcPath)){
return ;
}
if (!DirectoryExists(aimPath)){
ForceDirectories(aimPath);
}
if (FindFirst(srcPath + "//*.*", faAnyFile, sr) == 0){
do{
try{
if ((sr.Attr & faDirectory) != 0){ //folder
if (sr.Name != "." && sr.Name != ".."){
CopyFolder(srcPath+"//"+sr.Name, aimPath+"//"+sr.Name);
}
}else { //file
CopyFile((srcPath + "//" + sr.Name).c_str(), (aimPath + "//" + sr.Name).c_str(), 0);
}
}catch(...){}
} while (FindNext(sr) == 0);
FindClose(sr);
}
}
递归copy。