无法在 Metro 应用程序中访问资产文件 [英] Unable to access Asset files in Metro app

查看:32
本文介绍了无法在 Metro 应用程序中访问资产文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

I am trying to read a text file, which is shipped as an asset in a Metro app. I am receiving an access denied error, if specifying the file path as "ms-appx:///Assets/file.txt". Clearly I need to set some capability to access installation location folder. I tried enabling all capabilities in manifest designer, but still the same error. Please suggest.

解决方案

Try this:

StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(
    new Uri("ms-appx:///Assets/file.txt"));
Stream stream = await file.OpenStreamForReadAsync();
StreamReader sr = new StreamReader(stream);

这篇关于无法在 Metro 应用程序中访问资产文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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