获取的纯文本从RTF文本
问题描述:
我有我的数据库中保存的文本以RTF格式列。
I have on my database a column that holds text in RTF format.
如何得到它只是纯文本,使用C#?
How can I get only the plain text of it, using C#?
感谢:D
答
Microsoft提供一个例子他们基本上坚持了RTF文本在的RichTextBox
然后读。文
属性......感觉有点缺憾,但它的作品。
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;
}
}