开发者

Can't load Flowdocuments with xml entites from textfile

开发者 https://www.devze.com 2023-03-04 11:50 出处:网络
i doing a project with the wpf richtextbox control. I\'m saving the textfile with the xamlwriter class.

i doing a project with the wpf richtextbox control. I'm saving the textfile with the xamlwriter class.

When i'm trying to load the file everything is working really we开发者_开发百科ll except if there are html entities in the file. Because the overloaded XamlReader class only excepts a stream or a XmlReader, the html entities ( in this case '<' (&lt;) and '>' (&gt;) are expanded and loaded into the xamlreader where an exception occurs because it thinks '<' is an empty node.

Are there any known workarounds?

Thanks!


Ok.. got it. Loaded the xaml as a stream like so:

 public FlowDocument Load(string path)
    {
        using (StreamReader sReader = System.IO.File.OpenText(path))
        {
            using (Stream s = sReader.BaseStream)
            {
                return (FlowDocument)XamlReader.Load(s);
            }
        }
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号