Skip to content
⌘ NSIS Forum Archive

Append to End of File

6 posts

treaz#

Append to End of File

Hi,

I am using FileOpen and FileWrite to write some stuff into a file.
I am using append mode to do this.

However, when I do FileWrite, it seems to be writing to the begining of my file and overwriting my information in the file.

I wish to write to the end of the file not from the beginning.

Can anyone please help?
Thanks.!😕
pengyou#
Here is one way to add text at the end of a file:


FileOpen $R1 myfile.txt a
FileSeek $R1 0 END
FileWrite $R1 "this line should appear at the end$\n"
FileClose $R1
matini#
Originally posted by pengyou
Here is one way to add text at the end of a file:


FileOpen $R1 myfile.txt a
FileSeek $R1 0 END
FileWrite $R1 "this line should appear at the end$\n"
FileClose $R1
The codes should work but here is a note:
If the file doesn't have an empty line at the end, the text
will be appended to the last line.

e.g:
This is the last linethis line should appear at the end
virtlink#
I think that that can be solved by writing ($\r)$\n in front of 'this line should appear at the end', making "$\nthis line should appear at the end$\n".