Old 15th August 2003, 23:39   #1
hshim
Junior Member
 
Join Date: May 2003
Posts: 3
how to write at the end of existing file?

I opened a file with "a" mode to write a file.
It seems it appends the string from the beginning of the file.
I found a solution from this forum which is:

FileOpen $0 myfile a
FileSeek $0 END
FileWrite $0 "$\r$\nstring here$\r$\n"
FileClose $0

But my file is still refreshed, not appended.
Can someone help me?
hshim is offline   Reply With Quote
Old 16th August 2003, 01:20   #2
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
You need to specify an offset in addition to 'END'. You can use

FileSeek $0 0 END

to move to the very end of the file.

But this might not always give the result you expect - it depends upon the structure of the file (e.g. does it contain an EOF marker, do the existing lines in the file use $\r$\n or just $\n to mark the end of the line).
pengyou is offline   Reply With Quote
Old 16th August 2003, 12:30   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You should have a look at the NSIS Archive Text File Manipulation section.

There is a script on there which will write to the end of a file everytime.

-Stu
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump