Reputation: 317
So I want to export all the lines to a .txt file when a button is pushed. I got it to work but it also adds some other stuff to the .txt file.
Code I used for the button richedit1.Lines.SaveToFile('output.txt');
Ok now lets say I typed this in the richedit
Line1 test
Line2 test
Line3 test
Then I press the button and i get this output
{\rtf1\ansi\ansicpg1252\deff0\deflang7177{\fonttbl{\f0\fnil\fcharset0 Tahoma;}} \viewkind4\uc1\pard\f0\fs24 Line1 test\par Line2 test\par Line3 Test\par }
Is there any way to only show the lines in the richedit to the output.txt file?
Upvotes: 5
Views: 2631
Reputation: 317
Set the PlainText
property of the rich edit control to True
before calling SaveToFile
.
The documentation for this property says:
Controls whether the rich edit control treats the text as plain text or rich text when streaming to or from a file.
To write the rich text in the control to a plain text file, set PlainText to true before streaming the text to a file. To ignore the rich text information encoded in a file, set PlainText to true before streaming the text to the control.
To stream in the rich text attributes encoded in a file, or save the encoding of the rich text attributes to a file, set PlainText to false.
Upvotes: 7