c# - WPF: File not found -
this question has reply here:
filenotfoundexception reading json file assets folder in windows store app 1 replyi using class homecoming content of json file, having problem finding json file. might missing obvious, clueless may be.
i appreciate if 1 of hardcore programmers on code , pictures below. (i can't utilize images in posts yet sorry!)
image error , solution explorer:
namespace mvvm.model { class jsonhandler { private jsonarray _placeholder; public jsonarray placeholder { { homecoming _placeholder; } set { _placeholder = value; } } public jsonhandler() { extractjson(); } private async void extractjson() { uri datauri = new uri("ms-appx:///model/sampledata.json"); storagefile file = await storagefile.getfilefromapplicationuriasync(datauri); // json string jsontext = await fileio.readtextasync(file); jsonobject jsonobject = jsonobject.parse(jsontext); jsonarray jsonarray = jsonobject["restaurent"].getarray(); this.placeholder = jsonarray; } } }
in properties sampledata.json
, create sure have set build action "content" , copy output directory "copy always".
c# json wpf
No comments:
Post a Comment