'File already exists' error during a FoxPro build
If you see this unhelpful message while you're building your VFP application, here's how to deal with it.
By Mike Lewis
When you build an application in Visual FoxPro, you might sometimes see a "File already exists" error message. This is especially likely if you are using Windows 7 or above. The message is misleading and unhelpful. It doesn't tell you which file already exists, and in any case, it's not caused by trying to overwrite an existing file, as the wording suggests.
The most likely reason for the error is that VFP is trying to write to a file within the Program Files directory. That's something that recent versions of Windows are reluctant to permit.
You'll see the message if your project is stored within the VFP directory, and if that directory in turn is stored under Program Files. If that's the case, the solution is to move the project to a different location.
Even if the project itself is not stored under Program Files, it's possible that some of its components are. The project might include files in the FoxPro Foundation Classes (FFC), or in VFP's samples or wizards folders. These are typically located within the VFP directory in Program Files.
Again, the solution is to copy the relevant components to a different location, ideally to a sub-directory within your project's main folder. (Keep in mind that you will no longer be able to use VFP's HOME() function to locate these components; instead, make sure that their new folder is referenced from your SET PATH command.)
Why does VFP need to write to these folders during the build? This will happen if you have checked the Recompile All Files option in the Build Options dialog. It is the compiled object code that FoxPro is attempting to write.
Normally, there's never any need to recompile the FFC or other supplied classes. But if you choose to recompile the entire project, VFP will attempt to recompile the supplied classes as well. If you don't check that option, the chances are that you'll never see the error message.
Please note: The information given on this site has been carefully checked and is believed to be correct, but no legal liability can be accepted for its use. Do not use code, components or techniques unless you are satisfied that they will work correctly with your sites or applications.