Reference/FileOpen: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
mNo edit summary |
m (→FileOpen) |
||
Line 5: | Line 5: | ||
Opens a file named "filename", and sets the handle output variable with the handle. The openmode should be one of "r" (read) "w" (write, all contents of file are destroyed) or "a" (append, meaning opened for both read and write, contents preserved). In all open modes, the file pointer is placed at the beginning of the file. If the file cannot be opened, the handle output is set to empty, and the error flag is set. | Opens a file named "filename", and sets the handle output variable with the handle. The openmode should be one of "r" (read) "w" (write, all contents of file are destroyed) or "a" (append, meaning opened for both read and write, contents preserved). In all open modes, the file pointer is placed at the beginning of the file. If the file cannot be opened, the handle output is set to empty, and the error flag is set. | ||
If no absolute path is specified the current folder will be used. The current folder is the folder set using the last [[Reference/SetOutPath|SetOutPath]] instruction. If you have not used [[Reference/SetOutPath|SetOutPath]] the current folder is [[Reference/$EXEDIR|$EXEDIR]. | If no absolute path is specified the current folder will be used. The current folder is the folder set using the last [[Reference/SetOutPath|SetOutPath]] instruction. If you have not used [[Reference/SetOutPath|SetOutPath]] the current folder is [[Reference/$EXEDIR|$EXEDIR]]. | ||
<highlight-nsis>FileOpen $0 $INSTDIR\file.dat r | <highlight-nsis>FileOpen $0 $INSTDIR\file.dat r |
Latest revision as of 17:10, 6 June 2013
FileOpen
user_var(handle output) filename openmode
Opens a file named "filename", and sets the handle output variable with the handle. The openmode should be one of "r" (read) "w" (write, all contents of file are destroyed) or "a" (append, meaning opened for both read and write, contents preserved). In all open modes, the file pointer is placed at the beginning of the file. If the file cannot be opened, the handle output is set to empty, and the error flag is set.
If no absolute path is specified the current folder will be used. The current folder is the folder set using the last SetOutPath instruction. If you have not used SetOutPath the current folder is $EXEDIR.
FileOpen $0 $INSTDIR\file.dat r FileClose $0
Command introduced with NSIS v1.60