system.pathForFile returning nil

I’m porting another app and it keeps crashing because system.pathForFile(fileName,system.ResourceDirectory) and local file = io.open(path, “r”) returns nil.

And: bad argument #1 to ‘open’ (string expected, got nil)

 

What I am missing? Thanks.

 

Edit:

 

It seems to be windows doesn’t want to open .json files. 

 

Is this a known issue? Is there a work around?

Odds are your JSON files’ “Build Action” are not flagged as “Content”.  This tells Visual Studio to include your asset files within the compiled app bundle.  Please see step 5 and 6 from the link below on how to do this.

   http://docs.coronalabs.com/daily/coronacards/wp8/portapp.html#copying-project-files

For you info, we warn about this in the above link in the “Notes” box, bullet 3.  Visual Studio will only automatically flag certain file extension as “Content”.  For file extensions Visual Studio does not recognize, it will do nothing with them.  This is definitely true of *.json, *.ttf, and *.otf.  You might want to double check that all of your files under “Assets\Corona” are flagged as “Content” just in case.

Odds are your JSON files’ “Build Action” are not flagged as “Content”.  This tells Visual Studio to include your asset files within the compiled app bundle.  Please see step 5 and 6 from the link below on how to do this.

   http://docs.coronalabs.com/daily/coronacards/wp8/portapp.html#copying-project-files

For you info, we warn about this in the above link in the “Notes” box, bullet 3.  Visual Studio will only automatically flag certain file extension as “Content”.  For file extensions Visual Studio does not recognize, it will do nothing with them.  This is definitely true of *.json, *.ttf, and *.otf.  You might want to double check that all of your files under “Assets\Corona” are flagged as “Content” just in case.