阅读的Windows Phone 8.1运行系统项目文件夹中的文本文件 [英] Read text file in project folder in Windows Phone 8.1 Runtime

查看:132
本文介绍了阅读的Windows Phone 8.1运行系统项目文件夹中的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想读我的项目的根文件夹一个文件.TXT到我在第一次启动应用程序的数据库,但我不知道该怎么做。任何人都知道我可以做到这一点,请大家帮我...谢谢

I want read one file .txt in root folder of my project into my database at first time application launch, but I don't know how to do that. Anyone know how can I do that, please help me... Thanks

我在的Windows Phone 8.1的工作运行。

I'm working in Windows Phone 8.1 Runtime.

推荐答案

如果你想读您的项目中的文件例如,您可以做到这一点是这样的:

If you want to read a file from your project you can for example do it like this:

string fileContent;
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(@"ms-appx:///example.txt"));
using (StreamReader sRead = new StreamReader(await file.OpenStreamForReadAsync()))
fileContent = await sRead.ReadToEndAsync();

另外,请确保您已设置的生成操作您的文件中的内容的(应该为默认值)。

更多关于 URI方案,你会发现这里在MSDN

这篇关于阅读的Windows Phone 8.1运行系统项目文件夹中的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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