.net - c# Windows Phone cannot find json file -


i'm trying read data json file in .net 4.5 windows phone app. after pressing button exception appears saying:

system.io.filenotfoundexception (exception hresult: 0x80070002) 

my code:

public static async task readfile() {     storagefolder local = windows.applicationmodel.package.current.installedlocation;      if (local != null)     {         var file = await local.openstreamforreadasync("bazadanych.json");          using (streamreader streamreader = new streamreader(file))         {             json = streamreader.readtoend();         }     } } 

here's view of solution explorer:
enter image description here

you're not copying file local storage.

put json file under assets folder, make sure it's properties says "content" , "copy always"

on first launch should read json package

var filename = "assets/bazadanych.json"; var sfile = await storagefile.getfilefrompathasync(filename); var filestream = await sfile.openstreamforreadasync(); 

and store local storage.

there example windows 8 (which more or less same)

related question.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -