namespace simpleton public partial class AddNewOE : Window { //db connection simpletonDBEntities _db = new simpletonDBEntities(); public AddNewOE() { InitializeComponent(); } private void insertobBtn_Click(object sender, RoutedEventArgs e) { db_entry newdb_entries = new db_entry() { ReportDetails = ConvertRtbToBytes(rtfText) }; _db.ob_entries.Add(newOb_entries); _db.SaveChanges(); } public static byte[] ConvertRtbToBytes(string richTextBox) { byte[] data = null; string rtfText; //string to save to db TextRange tr = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd); using (MemoryStream ms = new MemoryStream()) { tr.Save(ms, DataFormats.Rtf); rtfText = Encoding.ASCII.GetString(ms.ToArray()); } return data; } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)