cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
absduser
Level 3

InstallScript Open File error

I need to create a file and write to it, while installation.
I tried the createfile and it kept giving me -1 error.

So I now have my file created before and copy it to the destination and try to use OpenFile and still get -1 status. (what do I need to do before opening or creating).

I am doing this in the OnBegin routine (so not much has occured prior to these calls).

appreciate your help.

thank you very much.
Labels (1)
0 Kudos
(5) Replies
dan_galender
Level 10

How about posting your code?
0 Kudos
absduser
Level 3

here is my code


STRING srcpath, dstpath, filename;
NUMBER nResult, nvFileHandle;

filename = "sample.txt";
dstpath = "c:\temp";
srcpath = SRCDISK + "\\Data";

XCopyFile(srcpath, dstpath, COMP_NORMAL);

nResult = OpenFile(nvFileHandle, dstpath, filename);


(XCopyFile is successful, the file is in the temp folder).
nResult is always -1.
0 Kudos
absduser
Level 3

the XCopyfile section (looks incorrect in the extract I posted.

it should really be -
copy the entire folder (I have functions that do it)

here is what exactly happens.


filetocopy = srcpath + "\\" + filename;
XCopyFile(filetocopy, dspath, COMP_NORMAL);
0 Kudos
dan_galender
Level 10

The problem may be in the dstpath spec. In a quoted string you need to double up the backslashes (as you did prior to "Data").

You might try changing

filename = "sample.txt";
dstpath = "c:\temp";
srcpath = SRCDISK + "\\Data";


to

filename = "sample.txt";
dstpath = "c:\\temp";
srcpath = SRCDISK + "\\Data"; // or srcpath = SRCDISK ^ "Data";
0 Kudos
absduser
Level 3

Dan,
thanks for the pointer.

I just checked, my code is correct in the project (my bad on typing it here for the forum) - you see I cannot do a cut and paste, they are on 2 different (disconnected servers).

any other suggestions?

thanks very much.
0 Kudos