如何在 WP7 应用程序中嵌入和读取文本文件? [英] How do I embed and read a text file ina WP7 app?

查看:33
本文介绍了如何在 WP7 应用程序中嵌入和读取文本文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试包含一个文本文件,其中包含一些我需要在应用程序启动时读取的静态数据.我已经添加了文件并将构建操作标记为资源",但我不确定如何将其作为流实际读取.有人知道怎么做吗?

I'm trying to include a text file that contains some static data that I need to read in when the app starts up. I've added the file and marked the Build Action to "Resource" but I'm unsure of how to actually read it in as a stream. Anyone know how to do this?

推荐答案

您可以使用 System.Windows.Application.GetResourceStream 方法:

var resource = System.Windows.Application.GetResourceStream(
                   new Uri("textfile.txt",UriKind.Relative));

应该做的伎俩

这篇关于如何在 WP7 应用程序中嵌入和读取文本文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆