Is there a command which will copy Multiple files using a wild card? I have tried
CopyFile("C:\\Source\\*.*", "C:\\Destination\\", FALSE);
and
CopyFile("C:\\Source\\*.ext", "C:\\Destination\\", FALSE);
Neither have worked. On-line help does not say it won't work, and the VB version example uses my second example above.
This function works only on one file at a time, so you should include your call into a loop controlled by FindFirstFile() and FindNextFile() in order to scan all the files that match your criteria. For example:
This will do the trick. I still would like to know if there is a function that will copy wild cards. I can't help but think that there is a function that will do this. Do you know of one?
Like I said, this will get me through the problem I am having and is probably a better way of handling the copying anyway..
When I use the code you supplied, this is returned..
CString SourcePath = "C:\\Source\\Files\\*.*";
HANDLE hFile = FindFirstFile(SourcePath, &pwfd);
CString Destination = "C:\\Destination\\Files\\" + pwfd.cFileName";
if(hFile != INVALID_HANDLE_VALUE)
{
CopyFile(pwfd.cFileName, Destination, FALSE);
}
pwfd.cFileName is equal to a . (dot) nothing else.
I know my paths are good and there are files in the source path.
What's wrong?
Thank-you
J.R.
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
WIN32_FIND_DATA pwfd;
HANDLE hFindFile = FindFirstFile("C:\\Source\
if (hFile != INVALID_HANDLE_VALUE)
{
BOOL rc;
do
{
CopyFile(pwfd.cFileName, ...);
rc = FindNextFile(hFindFile, &pwfd);
}
while (rc != FALSE);
FindClose(hFindFile);
}