private void btnSave_Click(object sender, RoutedEventArgs e) { FileStream fileStream = File.Create("Console.log"); rtbConsoleOutput.SelectAll(); TextSelection textSelection = rtbConsoleOutput.Selection; textSelection.Save(fileStream, DataFormats.Text); fileStream.Flush(); fileStream.Close(); }
internal void Copy() { FlowDocumentScrollViewer viewer = this.Viewer; TextSelection selection = viewer.Selection; if (!selection.IsEmpty) { DataObject data = new DataObject(); data.SetText(selection.Text); MemoryStream rtf = new MemoryStream(); selection.Save(rtf, DataFormats.Rtf); rtf.Seek(0, SeekOrigin.Begin); StreamReader reader = new StreamReader(rtf); string rtfText = reader.ReadToEnd(); data.SetData(DataFormats.Rtf, rtfText); Clipboard.SetDataObject(data); } }