Archive: Having trouble with appending to end of file


Having trouble with appending to end of file
This is the code I have:


Var /GLOBAL Log
StrCpy $Log "$DESKTOP\Uninstall_Log.txt"
Var /GLOBAL LogFile
FileOpen $LogFile $Log w
FileWrite $LogFile "Uninstall Log$\r$\n"
FileClose $LogFile

;Do some other stuff

FileOpen $LogFile $Log a
FileWrite $LogFile "Version: $Version$\r$\n"
FileClose $LogFile


However, when this code executes, all I see in the file is this:
Version: 6.3
Why is it not appending to the file?

It's all in the manual: http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.5.2

"In all open modes, the file pointer is placed at the beginning of the file."


Ah ok. So can I keep the file open throughout the whole script? If in between the NSIS FileWrite calls, I append stuff to the file by another means, will the file pointer move as I append? or will it stay at the last NSIS append?

Edit: I can use FileSeek to do this?


Yes, use FileSeek (see http://nsis.sourceforge.net/Simple_write_text_to_file). If it is only the installer that is writing to the file, you may keep the file handle open for the full duration of the install. Have you thought about using the logging build of NSIS too?

Stu