PDA

View Full Version : writing text to the end of a file


zworp
12-02-2003, 03:54 PM
Hi there.

Im trying to write data to the end of a text-file, beneath the old text.
But it seems that the text thats already in the file gets written over if I use the fprint function,

How should I solve this?

thanks for any help.

/jan

mhovland
12-02-2003, 05:39 PM
When you open your file for writing, using fopen , make sure you are opening the file for "append", like so:

string $myFile = "C:\\TestFile.txt";
$fileID = `fopen $myFile "a"`;

See if that doesn't work for you.

zworp
12-02-2003, 05:57 PM
ahh thanks. great!
that was exactly what I wanted.
I was only looking at the print commad in the docs, forgot about open.

CGTalk Moderation
01-16-2006, 07:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.