-2
我在C#中遇到RichTextBox问题。从.rtf文件到RichTextBox的路径
当我尝试负载RichTextBox的文字,如 “C:\用户\ adasal \桌面\ raporty_handel \ RPT \ RTF \ bruegman.rtf” 从.rtf文件我gettingn类似 “C:_handel.rtf”
此代码在Active Reports控制台中写入。
我的代码:
string resoult = "C:\\Users\\adasal\\Desktop\\raporty_handel\\rpt\\rtf\\bruegman.rtf"
System.IO.FileStream rtfCreate = System.IO.File.Create(resoult);
System.Byte[] info = new System.Text.UTF8Encoding(true).GetBytes(resoult);
rtfCreate.Write(info, 0, info.Length);
rtfCreate.Close();
System.IO.FileStream streamRTF = new System.IO.FileStream(resoult,
System.IO.FileMode.Open, System.IO.FileAccess.Read);
this.RichTextBox1.Load(streamRTF, RichTextType.Rtf);
有人能帮忙吗?我想在报告中显示整个路径。
你目前的例子对我来说没有什么意义,你能否试着解释你到底想要做什么?对我来说,它现在看起来像是在'resoult'指定的位置写入文件名('resoult')到一个新文件中。由于'resoult'的内容不是有效的RTF,所以'RichTextBox'只会显示你看到的破碎文本。您需要创建一个有效的RTF文件,以使RichTextBox能够正确加载它。 – bassfader
我想创建一个.rtf文件并将其插入到导致它的文本路径中。 – adsal90