我在应用中有一个文本文件。有人可以通过算法解释如何在文本块中显示文件的内容。
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.
答案 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保存为项目中的内容