furiousNoob
furiousNoob

Reputation: 53

How to fill richtextbox from memory stream?

I want to fill richtext box with the values of a text file. The text file will come from the database. I have done this code so far.

 Byte[] txtdata = (Byte[])(objDataSet.Tables[0].Rows[0][7]);
 MemoryStream txtmem = new MemoryStream(txtdata);
 richTextBox_Show_Spec.LoadFile(txtmem,RichTextBoxStreamType.RichText);

But nothing shows in that richtextbox. Any help is appreciated. Thanks

Upvotes: 2

Views: 3135

Answers (1)

selkathguy
selkathguy

Reputation: 1171

I would just use the Encoding namespace to get a character string from your bytes. Like richTextBox.Text = Encoding.UTF8.GetString(txtmem.ToArray()); or similar.

That way you can still store formatting information should you ever choose to support things like text size or color.

Upvotes: 3

Related Questions