c#如何保存richtextbox的rtf格式


C# code
this.rtbText.Rtf = @"{\rt f1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052"
+ @"{\fonttbl{\f0\fmodern\fprq6\fcharset134 \ 'cb\ 'ce\ 'cc\ 'e5;}{\ f1\fnil\fcharset134 \ 'cb\ 'ce\ 'cc\ 'e5;}}"
+ @"{\colortbl;\red0\green0\blue0;}"
+ @"\viewkind4\uc1\pard\c f1\lang2052\f0\cf1 }";
打开文件,如果是文本文件,用PlainText类型打开,其他的都用默认方法打开,也就是RFT格式的方法
if ((System.IO.Path.GetExtension(FileName)).ToLower() == ".txt")
richTextBox.LoadFile(FileName, RichTextBoxStreamType.PlainText);
else
richTextBox.LoadFile(FileName);

保存
if ((System.IO.Path.GetExtension(FileName)).ToLower() == ".txt")
richTextBox.SaveFile(FileName, RichTextBoxStreamType.PlainText);
else
richTextBox.SaveFile(FileName);


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM