将.txt文件加载到FlowDocument中

本文关键字:FlowDocument 加载 txt 文件 | 更新日期: 2023-09-27 17:57:47

如何将.txt文件加载为FlowDocument以将其放入RichTextBox

将.txt文件加载到FlowDocument中

下面是一个非常简单的方法。

using (var fs = new FileStream(FileName, FileMode.OpenOrCreate))
{
     var range = new TextRange(Document.ContentStart, Document.ContentEnd);
     range.Load(fs, DataFormats.Text);
}

你试过谷歌吗?

http://www.c-sharpcorner.com/uploadfile/mahesh/loading-a-text-file-in-a-wpf-flowdocumentreader/

将XAML转换为FlowDocument以显示在WPF 的RichTextBox中