Unable to access Asset files in Metro app

心已入冬 提交于 2019-12-20 04:28:19

问题


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.


回答1:


Try this:

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



回答2:


Is that exactly the reference you are using? Try

ms-appx:///Assets/file.txt


来源:https://stackoverflow.com/questions/12910627/unable-to-access-asset-files-in-metro-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!