【发布时间】:2014-04-03 12:48:07
【问题描述】:
我想用 StreamReader 读取一个 txt 文件,然后把它交给 TextBlock。该代码适用于 Windows Phone 应用程序,使用 C#:
var resource = System.Windows.Application.GetResourceStream(new Uri("File.txt", UriKind.Relative));
StreamReader sreader = new StreamReader(resource.Stream);
while ((line = sreader.ReadLine()) != null)
{
TextBlock.Text = sreader.ReadLine();
}
这会将文件中的所有文本读取到我的 TextBlock 中,但其中有特殊字符,例如 ä 或 ü 或 ö,它们不会显示在 TextBlock 中。如何在我的 TextBlock 中显示这些字符?
【问题讨论】:
标签: c# text windows-phone-8 streamreader