编程语言
首页 > 编程语言> > C# 之Richtextbox保存为Byte[] 和读取Byte[]

C# 之Richtextbox保存为Byte[] 和读取Byte[]

作者:互联网

将richtextbox内容保存为字节数组Byte[]

//使用内存流
using (MemoryStream savefilestream = new MemoryStream())
{
     richTextBox1.SaveFile(savefilestream, RichTextBoxStreamType.RichText);
     Byte[] bt = savefilestream.ToArray();
}

将richtextbox读取字节数组Byte[]

//从数据库中读出Byte[]
Byte[] bt = (Byte[])rd[0];
//MessageBox.Show(bt.Length.ToString());
MemoryStream fm = new MemoryStream(bt);
richTextBox1.LoadFile(fm, RichTextBoxStreamType.RichText);
fm.Close();

标签:MemoryStream,C#,Richtextbox,richTextBox1,bt,Byte,fm,savefilestream
来源: https://blog.csdn.net/qq_45623310/article/details/112716532