Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 从RichTextBox提取原始RTF_C#_Wpf_Wpf Controls_Rtf - Fatal编程技术网

C# 从RichTextBox提取原始RTF

C# 从RichTextBox提取原始RTF,c#,wpf,wpf-controls,rtf,C#,Wpf,Wpf Controls,Rtf,一定有比我现在做的更好的方法 我试图从WPF RichTextBox中提取原始RTF。实际上,我正试图将一组自定义类转换为RTF字符串,但我使用RichTextBox来实现,因为我并不特别想编写自己的RTF库 我使用的方法(从第一次看到并用于提取XML的内容修改而来)如下所示: RTB.Selection.Save(memstream, DataFormats.Rtf); memstream.Seek(0, SeekOrigin.Begin); var sr = new StreamReader

一定有比我现在做的更好的方法

我试图从WPF RichTextBox中提取原始RTF。实际上,我正试图将一组自定义类转换为RTF字符串,但我使用RichTextBox来实现,因为我并不特别想编写自己的RTF库

我使用的方法(从第一次看到并用于提取XML的内容修改而来)如下所示:

RTB.Selection.Save(memstream, DataFormats.Rtf);
memstream.Seek(0, SeekOrigin.Begin);
var sr = new StreamReader(memstream);
var myText = sr.ReadToEnd();
这是可行的,但看起来笨拙得可笑。我担心大量文本的性能影响。有更好的办法吗?(就本问题而言,假设我不能使用WinForms RichTextBox。)

使用问题

string mpic = @"{\pict\pngblip\picw" + 
    img.Width.ToString() + @"\pich" + img.Height.ToString() +
    @"\picwgoal" + width.ToString() + @"\pichgoal" + height.ToString() + 
    @"\bin " + str + "}"
使用疑问句

string mpic = @"{\pict\pngblip\picw" + 
    img.Width.ToString() + @"\pich" + img.Height.ToString() +
    @"\picwgoal" + width.ToString() + @"\pichgoal" + height.ToString() + 
    @"\bin " + str + "}"