Reading Files in Windows Phone 8: Value does not fall within the expected range

两盒软妹~` 提交于 2019-12-02 03:06:27

I noticed that I get that error if I use the shash / in the path to the file. Instead, if I use backslash \ I can get the files.

Try following way:

StorageFile sFile = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"Assets\Data\htm\" + fileName + ".htm");

var fileStream = await sFile.OpenStreamForReadAsync();

Note that you have to place an @ before the path string to avoid the intepretation of \ as scape character.

You could also get the file stream this way:

var fileStream = File.OpenRead("Assets/Data/htm/" + fileName + ".htm");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!