sazr
sazr

Reputation: 25938

Writting file contents to new file only writes half the string

I am attempting to do a very simple task which is read a file in NSIS then write those file contents to a new file.

My Problem: Not all the file contents are being written to the new file, only half is. Whats going wrong?

Jeez NSIS is giving me alot of headaches lately :(

Heres my code:

Section
    #Read file
    StrCpy $R9 ""             #$R9 will hold the file contents
    FileOpen $R7 "C:\MyFolder\usermenu.4d" "r"

    ReadFileLoop:
        FileRead $R7 $R6
        StrCpy $R9 "$R9$R6"
        #DetailPrint "$R6"
        IfErrors +1 ReadFileLoop

    FileClose $R7

    #Write file contents to new file
    ClearErrors
    FileOpen  $3 "C:\Users\me\Desktop\abc.txt" w
    FileWrite $3 "$R9"
    FileClose $3
SectionEnd

Upvotes: 0

Views: 64

Answers (1)

Anders
Anders

Reputation: 101736

NSIS variables have a fixed size, if the file is larger than the limit some of it is not going to fit. You should write to the other file as part of the reading loop.

And of course, if you want a unmodified copy you can just use CopyFiles...

Upvotes: 2

Related Questions