在C#中展示嵌入的RTF文件

        在c#程序中展示嵌入的RTF文件是相当容易的--在Windows表单的富文本控件里(RichTextControl).

 首先,添加一下引用:

1  using System.IO;  

2  using System.Reflection;

 

其次,加载这个你嵌入到你项目中的RTF文件。

 

1Assembly asm = Assembly.GetExecutingAssembly();

2Stream stream =   asm.GetManifestResourceStream( "MyNamespace.FileName.rtf" ); 

 3 RichTextBox rt = new RichTextBox();

4 rt.LoadFile( stream, RichTextBoxStreamType.RichText );

 

 在这里加载嵌入的资源文件最重要就是得到正确的路径。

 

posted @ 2008-07-24 10:50  Lucky Jack  阅读(868)  评论(0编辑  收藏  举报