View Full Version : XCopyFile error with locked files

09-08-2003, 05:02 PM
I am trying to copy a locked file with xcopyfile. I am receiving the following error:
Cannot create a file when that file already exists

Here is my code snippet:

nResult = XCopyFile("C:\\temp\\test.txt", "C:\\test.txt",COMP_NORMAL|LOCKEDFILE);
if (nResult <0) then
nResult = CommitSharedFiles(0);

Shouldn't this snippet copy a backup file to c:\\ and then create a run once entry in the registry to replace this file on reboot. None of this is happening. I am not using SRCDIR and TARGETDIR as the documentation says if you use fully qualified paths, it is not necessary.
Am I doing something wrong? I am trying to do this without calling the sdfinish/sdfinish reboot dialog.
Thanks in advance!

09-09-2003, 07:43 AM
The second parameter in XCopyFile (szSrcFile, szTargetPath, nOp); should be the target path only not the file name. I am not sure whether this is creating the problem. But you can give it a try.

Niran Bhimaiah

09-09-2003, 10:44 AM
That worked! Thanks so much! I completely missed it.