天天看點

C# 将RichTextBox中内容的文檔以二進制形式存

private void button1_Click(object sender, EventArgs e)

        {

             System.IO.MemoryStream mstream = new System.IO.MemoryStream();

            this.richTextBox.SaveFile(mstream, RichTextBoxStreamType.RichText);

            bWrite = mstream.ToArray();

            //如需儲存,則以二進制的形式存入資料庫.

            //sqlHelper.RunSql("insert into XXX (XX) values (@XX)", pram);

        }

        private void button2_Click(object sender, EventArgs e)

            //  DataTable dt=sqlHelper.GetDataTable("select XX from XXX where .....");

           // byte[] bWrite = (byte[])dt.Rows[0][0];

            System.IO.MemoryStream mstream = new System.IO.MemoryStream(bWrite, false);

            this.richTextBox.LoadFile(mstream, RichTextBoxStreamType.RichText);