Vinay Sathyanarayana
Vinay Sathyanarayana

Reputation: 460

Convert richtextbox text into a stream c#

I have a richtextbox control in a C# winform application which contains formatted data (bold, italicized, underlined, center aligned etc). I want to load this formatted text present in the richtextbox to a Stream in C# without losing the formatting.

Currently, when I get the data from richtextbox to a stream, the formatting information is being lost and not present in the stream. Any advise/inputs on how to do this? Thanks in advance.

Upvotes: 2

Views: 3700

Answers (1)

shfire
shfire

Reputation: 847

As Zec said, you can use RTF property var stream = new MemoryStream(Encoding.Unicode.GetBytes(richTextBox1.Rtf));

Upvotes: 5

Related Questions