Copy Fails of Files
Posted 15 May 2006 - 12:02
I have the following code to copy a zip file from the current directory.
nvResult = CopyFile(".\\test.zip", path + "\\" + TestFolder + "\\test.zip");
if(nvResult < 0) then
MessageBox("Copy Failed ", INFORMATION);
svErrorMessage = FormatMessage( nvResult );
SprintfBox( WARNING, "CreateDir Error",
"CreateDir failed!\n\nError code: %ld\nMessage text: %s",
nvResult, svErrorMessage );
MessageBox("Copy SuccessFul ", INFORMATION);
I have build the script and the name of the executable file is Test.exe. When I build there are two exe's created namely the usual setup.exe and Test.exe . when I run the setup.exe the copy works fine, but when I run the Test.exe the copy fails.
Could anyone give me some hint on why this happens.
Posted 15 May 2006 - 16:27
Posted 16 May 2006 - 04:26
You had asked me what this Test.exe is basically the project that I have created is an InstallScript Project. In the Product Properties, there is an option to specify the [I]Executable File[I], and there I have specified it as Test.exe. Now when I build (i.e. Build Release 1) for this project the following listed folders are generated
- Disk Images
- Log Files
- Report Files
In the Package folder Test.exe is created, this is the file that I am refering to, and additionally in the folder Disk Images there is a folder called Disk 1 which has a setup.exe. So its the Test.exe from the Package Folder that I run to do the copy. and it doesnt work. Could provide me with the hint on why this doesnt work.
Posted 16 May 2006 - 11:29
Posted 16 May 2006 - 11:40
You are correct, the execution happens in a temp folder. But I am also creating a batch file in the CURRENT DIRECTORY from where this Test.exe will be executed, that is being created correctly, only the copying fails. Could you say me how I can over come this problem
Posted 19 May 2006 - 06:28
But PACKAGE_LOCATION gives the fully qualified file name in my example if the Test.exe is being executed from a folder called "C:\Test", then PACKAGE_LOCATION gives you "C:\Test\Test.exe".
So should I truncate the last part and use this as the location or is there a better way to do this.
Its actually strange that this doesnt work, because currently I am using "." to create a batch file in the folder.
Posted 19 May 2006 - 15:45
|So should I truncate the last part and use this as the location|
Test.exe extracts setup.exe to the temp folder. Then your setup runs from there, so .\ is the temp folder.
Posted 22 May 2006 - 04:45
I have fixed this using by doing the following.
ParsePath(pathOfSetup, PACKAGE_LOCATION, PATH);
nvResult = CopyFile(pathOfSetup + "\\test.zip", targetlocation+ "\\" + "test" + "\\test.zip");