//将richtext中文字+图片存入数据库
this.rtbText.SaveFile(mstream, RichTextBoxStreamType.RichText);
mstream.Position = 0;
SqlCommand cmd = new SqlCommand();
System.Data.SqlClient.SqlParameter[] pram = new System.Data.SqlClient.SqlParameter[] { };
cmd.Parameters.AddWithValue("@project_content",mstream.ToArray());
string sql = "insert into project values('" + cbbHospotal.Text + "','" + cbbType.Text + "','@project_content','未确认','待开发','','" + AllStatic.userName + "',getdate(),'','" + label2.Text + "')";
int i = sl.ExecuteNonQuery(sql,pram,CommandType.Text);
//从数据库读取至richtext
byte[] bWrite = (byte[])(dt.Rows[0]["project_content"]);
if (bWrite != null)
{
using ( MemoryStream mstream = new MemoryStream())
{
mstream.Write(bWrite, 0, bWrite.Length);
mstream.Position = 0;
//将stream填充到RichTextBox
this.richTextBox1.LoadFile(mstream, RichTextBoxStreamType.RichText);
} }
报错,文件格式无效