当前位置:编程学习 > C#/ASP.NET >>

WPF,XamlReader读取XAML文件,为什么报错?

在项目所在的文件夹,有个ttt.txt文件,其内容如下:
<TextBox Background="#FFFF0000" Width="34" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
我爱
</TextBox>


程序后台代码:

public MainWindow()
 {
    InitializeComponent();
    FileStream file = new FileStream("ttt.txt", FileMode.OpenOrCreate);
    TextBox textbox = (TextBox)XamlReader.Load(file);
 }

结果报错:给定编码中的字符无效。 第2行,位置1。

请问,哪里出错了呢?XamlReader的Load方法,就是这样用的啊
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,