C# – Get plain text from an RTF text

cnetrtf

I have on my database a column that holds text in RTF format.

How can I get only the plain text of it, using C#?

Thanks 😀

Best Answer

Microsoft provides an example where they basically stick the rtf text in a RichTextBox and then read the .Text property... it feels somewhat kludgy, but it works.

static public string ConvertToText(string rtf)
{
   using(RichTextBox rtb = new RichTextBox())
   {
       rtb.Rtf = rtf;
       return rtb.Text;
   }
}