Rudolf Smith
Rudolf Smith

Reputation: 21

Delphi saving to text file

Is there a way I can use coding Memo1.lines.savetofile ('textfile1.txt') without it then deleting whatever already is in the texfile to save the memos lines?

Upvotes: 1

Views: 4943

Answers (2)

Remy Lebeau
Remy Lebeau

Reputation: 598001

Create a TFileStream that opens the existing file, seek to the end of the stream, and then pass the stream to Memo1.Lines.SaveToStream().

Upvotes: 10

David Heffernan
David Heffernan

Reputation: 613461

Presumably you want to append the text to the file. Do that like so:

TFile.AppendAllText(FileName, Memo1.Text);

This uses the TFile class from the IOUtils unit. Pass an encoding parameter if you want to exercise control over the encoding used.

Upvotes: 4

Related Questions