一个API版本的目录copy函数
BOOL CopyFiles(CString szSrcDir, CString szDestDir, BOOL bfailIfExists)
{
if (!PathIsDirectory(szSrcDir))
{
return FALSE;
}
WIN32_FIND_DATA findFileData;
HANDLE hFind = ::FindFirstFile(szSrcDir + _T("*.*"), &findFileData);
if (INVALID_HANDLE_VALUE == hFind)
{
return FALSE;
}
BOOL bRet = TRUE;
while(bRet)
{
if(findFileData.cFileName[0] != _T('.'))
{
CString csFileName = findFileData.cFileName;
if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
{
int bRet = SHCreateDirectoryEx(NULL,szDestDir+csFileName,NULL);
if (bRet == ERROR_SUCCESS || bRet == ERROR_ALREADY_EXISTS)
{
BOOL bRet = CopyFiles(szSrcDir+csFileName+_T("\\"), szDestDir+csFileName+_T("\\"), bfailIfExists);
if (!bRet)
{
CloseHandle(hFind);
return FALSE;
}