问题
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