Try this one:
Code:
int CopyAllFiles (
char *wildStr,
char *srcPath,
char *dstPath
)
{
HANDLE hf;
BOOL goFlag = FALSE;
int reply;
WIN32_FIND_DATA ffData;
char srcFile[MAX_PATH], dstFile[MAX_PATH];
sprintf (srcFile, "%s\\%s", srcPath, wildStr);
hf = FindFirstFile (srcFile, &ffData);
for (goFlag=(hf!=INVALID_HANDLE_VALUE); goFlag; goFlag=FindNextFile(hf, &ffData)) {
if (ffData.dwFileAttributes == FILE_ATTRIBUTE_ARCHIVE) {
sprintf (srcFile, "%s\\%s", srcPath, ffData.cFileName);
sprintf (dstFile, "%s\\%s", dstPath, ffData.cFileName);
reply = CopyFile (srcFile, dstFile, TRUE);
}
}
if (hf!=INVALID_HANDLE_VALUE)
FindClose (hf);
return (0);
}
Call it like this:
CopyAllFiles ("*.exe", "C:\\Foo", "D:\\Bar");
Works for me. See on MSDN what third param of CopyFile() does and do whatever you want about it.