views:

16

answers:

0

Guys, I'm having this weird error with my application that is supposed to copy files from a directory given from the command line to another directory.

I'm using of course the three API functions; CreateFile, ReadFile, and WriteFile. I can't use the CopyFile API.

Note that the compiler doesn't report any errors nor any warnings.

hFile1 = CreateFile(argv[1], GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS, NULL);

hSearch = FindFirstFile((L"."), &hFind); if (hSearch == INVALID_HANDLE_VALUE) { _tprintf(L"No files found.\n"); }

do { if (ReadFile(hFile1, Buffer, BUFSIZE, &BytesRead, NULL)) {

cFile = WriteFile(hFile2, Buffer,
BytesRead, &BytesWritten,
NULL); if (!cFile) { _tprintf(L"Couldn't copy file.\n"); }

      }

} while (BUFSIZE == BytesRead);