将文本文件显示在已在应用程序内的文本块上

时间:2011-12-21 19:21:37

标签: c# visual-studio windows-phone-7 windows-phone-7.1

我在应用中有一个文本文件。有人可以通过算法解释如何在文本块中显示文件的内容。

PS: I would be obliged if you didn't downvote this question as I'm banned from questioning further and trying to rectify my mistakes. Thank you, good sir.

1 个答案:

答案 0 :(得分:2)

此代码加载了项目目录中的文件,并在TextBlock中显示,名称为textBlock

var rs = Application.GetResourceStream(new Uri("file.txt", UriKind.Relative));
StreamReader sr = new StreamReader(rs.Stream);
textBlock.Text = sr.ReadToEnd();

将file.txt保存为项目中的内容