c# richbox

//先保存为文件
             string  filename =  @"C:\Example.rtf" ;
             RichTextBox.SaveFile(filename);
 
 
             //然后读取文件转成btye[]
             byte [] output =  new  byte [0];
             try
             {
 
                 FileStream fs =  new  FileStream(filename, FileMode.Open, FileAccess.Read);
                 BinaryReader reader =  new  BinaryReader(fs);
                 reader.BaseStream.Seek(0, SeekOrigin.Begin);
                 output = reader.ReadBytes(( int )reader.BaseStream.Length);
             }
             catch  { }
 
             //读进rtf
             RichTextBox.Clear();
             RichTextBox.LoadFile(filename);

你可能感兴趣的:(c# richbox)