I'm having trouble with an application which moves files from one location to another, using the Windows API. The problem isn't the code, it appears to be the project settings, but I don't know what to look for or where.
I created a project, wrote a load of code and then got to implementing the move bit. On testing I kept getting an 'access denied' result. After lots of head scratching I created a new project to unit test the move code. It worked just fine. I copied the known working code wholesale into the original project, deleted everything else and reran it. Access Denied. So the only difference between the two projects is whatever is in the project settings. I also checked the security setting in Explorer for both exe files. Both are the same with me as the owner.
Please can anyone suggest what I need to check/change in the settings? I don't want to wade through trying to compare the both project settings manually.
Many thanks.
For anyone interested the code I'm running is:
#include <windows.h>
#include <string>
#include <stdio.h>
void main(int argc, char** argv)
{
std::string srcPath = "S:\\_UploadTests\\Oct_10";
std::string dstPath = "S:\\_archivedtests\\Oct_10";
BYTE flags;
flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING;
if (!MoveFileExA(srcPath.c_str(), dstPath.c_str(), flags)) {
fprintf(stderr, "Error moving folder to local archive. \n\tWindows returned code: %ld\n", GetLastError());
}
getchar();
}