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); } }