Reputation: 11184
using VS 2013, C#
I am trying to use JSON file in my project. Using next code (as in sample project from MS):
Uri dataUri = new Uri("ms-appx:///DataModel/MyData.json");
StorageFile fileToRequest = await StorageFile.GetFileFromApplicationUriAsync(dataUri);
string jsonText = await FileIO.ReadTextAsync(fileToRequest);
JsonObject jsonO = JsonObject.Parse(jsonText);
JsonArray jsonA = jsonO["Events"].GetArray();
As result got this:
and next step - exception file not found, but it exists
Also, if the same code launched with sample project from VS - all its ok. Code from sample project:
Uri dataUri = new Uri("ms-appx:///DataModel/SampleData.json");
StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(dataUri);
string jsonText = await FileIO.ReadTextAsync(file);
JsonObject jsonObject = JsonObject.Parse(jsonText);
JsonArray jsonArray = jsonObject["Groups"].GetArray();
Debugging of this code got:
So question - why I got exception FileNotFound
, why this file invisible for my project.
Upvotes: 8
Views: 2831