private void Button_Click(object sender, RoutedEventArgs e) { string savePth = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "richtextboxData.data"); using (System.IO.FileStream fs = new System.IO.FileStream(savePth, System.IO.FileMode.OpenOrCreate)) { var textrange = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd); textrange.Save(fs, DataFormats.XamlPackage); } } private void Button_Click_1(object sender, RoutedEventArgs e) { string savePth = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "richtextboxData.data"); TextRange textrange = new TextRange(rtb.Document.ContentStart, rtb.Document.ContentEnd); using (System.IO.FileStream fs = new System.IO.FileStream(savePth, System.IO.FileMode.Open)) { textrange.Load(fs, DataFormats.XamlPackage); } }
WPF RichTextBox 导出与加载
猜你喜欢
转载自www.cnblogs.com/nocanstillbb/p/10677095.html
今日推荐
周排行