The program below works fine on Windows 7 Home Edition. It just copies a couple of files from one location to another, renaming them in the process. As you can see, messages are printed to the screen to tell the user what is happening.
Originally, the program used the CopyFile lines that are now commented out. On W7, the program worked just fine, copying 2 mdb files from the mmtp folder to c:\ with new names. I was happy. (I'm a newbie at C++...for me this was a significant achievement.)
I wanted to make sure the program was portable so I copied the program to my Vista. It printed the messages just fine. But it did not copy the files. So I created the program from scratch on the Vista. (I have Visual C++ Express 2010 on both machines. The builds were sucessful on both machines with each trial.) I made sure the folder and files existed. Once more, it printed the messages, but didn't copy the files.
Stumped, I decided to replace the copyfile lines with the system copy lines you see in use below. Once again, the messages printed, but instead of copying files, the program printed this: The system cannot find the file specified. Not what I expected but it's a clue, right? Still, I don't understand why the program couldn't see the files.
Finally, I copied the mdb file to c:\ and tried again. Still no copying, but I got a new message "Access denied". Wow, another clue. The program can see the files now but can't copy them. Aghh! I'm not asking for much...just to copy a couple of files.
It seems it's not the code but something about Vista or the environment. Now you're where I am now. Actually, I hope you're not where I am because I don't have any idea what to do next and would appreciate your help.
Thanks so much for any ideas.
gk
Code:
#include <iostream>
#include <stdlib.h>
#include <io.h>
#include <Windows.h>
using std::cout;
using std::endl;
int main()
{
cout << "Preparing to copy..." << endl;
cout << endl;
cout << "Copying main database" << endl;
system("copy C:\\Consumer.mdb c:\\Austin.mdb");
//CopyFile("c:/mmtp/consumer.mdb","c:/Austin.mdb",FALSE);
cout << "Copying license file" << endl;
system("copy C:\\Consumer.mdb c:\\Austin.mdb");
//CopyFile("c:/mmtp/db8.mdb","c:/license.mdb",FALSE);
cout << endl;
cout << "Files copied" << endl;
system("pause");
return 0;
}