mmtmalone
8th January 2014, 20:18
I am trying to create a text file that I will eventually email to the user.
When I try to open the file, I get a -2 return value.
Can anyone tell me why????
I have verified that the path exists as I have another program that is using the same path and not having any trouble.
Here's my code:
temp.file = "app/data/installation/cust_avail_credit.txt"
seq.unlink(temp.file)
tfp = seq.open(temp.file,"wt+")
bdittmar
8th January 2014, 20:55
I am trying to create a text file that I will eventually email to the user.
When I try to open the file, I get a -2 return value.
Can anyone tell me why????
I have verified that the path exists as I have another program that is using the same path and not having any trouble.
Here's my code:
temp.file = "app/data/installation/cust_avail_credit.txt"
seq.unlink(temp.file)
tfp = seq.open(temp.file,"wt+")
Hello,
string openmode The mode in which the file must be opened. This can be one of the following options:
"r" Open for reading. The current file position is placed at the start of the file.
"w" Open for writing. The file is created if it does not already exist. The current file position is placed at the start of the file.
"a" Open for writing. The file is created if it does not already exist. The current file position is placed at the end of the file.
The file position is placed at end of the file before every write statement, even if the previous file action was a seq.seek().
"x" Open for writing. This is the same as "w", except that the function fails if the file already exists.
"r+" Same as "r", but the file can also be written to.
"w+" Same as "w", but the file can also be read.
"a+" Same as "a", but the file can also be read.
"x+" Same as "x", but the file can also be read.
Use the following modes to indicate whether the file is a binary or a text file. You can combine one of these modes with any one of the previous modes (for example, "rt+").
"b" Use for binary files. This is the default mode and need not be specified.
"t" The line separator(s) for text-files are different on Windows NT and UNIX systems. CRLF on the former; LF only on the latter. In addition, a Windows NT text file can include an EOF-character (^Z) that indicates the end of the file. This character should not be returned to a program reading the file.
So, you must specify the "t" option when reading from or writing to a text file on Windows NT systems (for example, "at+".) This ensures that line separators and EOF characters are handled correctly. Never use the "t" option when opening a binary file; on Windows NT systems this will corrupt the file data. The "t" option has no effect on UNIX systems.
Normaly -2 says:
ENOENT
No such file or directory
This occurs when a specified file name should exist but does not, or when one of the directories in a path name does not exist.
2 ENOENT - No such file or directory
Description:
This error occurs when a specified file name should exist but does not, or when one of the directories in a path name does not exist.
Solution:
Possible solutions:
If a file or directory is missing, you must create the file or directory or restore them using a backup.
If a table is missing, check the company number. Your current company number can be different from the company number the Virtal Machine is using.
The file or directory exists, but still the error occurs. Check the redirection of the files.
Try to use FULL path :
temp.file = "app/data/installation/cust_avail_credit.txt"
temp.file = "/app/data/installation/cust_avail_credit.txt"
Regards
mmtmalone
8th January 2014, 23:03
qualifying the entire directory did the trick
didn't realize that I missed that
Thanks!!!