Page 1 of 1

StreamReader and File Path

Posted: Fri Nov 01, 2019 2:02 am
by KenX
I encountered a problem using StreamReader to read a JSON file "LangData_enUS.json" from folder "Languages" in the solution root directory.

I must specify the path as "./Output/Languages/LangData_enUS.json" to work in the simulator like below:

Code: Select all

using (var _stream = new StreamReader("./Output/Languages/LangData_enUS.json", Encoding.UTF8))
{
   string _json = await _stream.ReadToEndAsync();
   var _jsonObj = await JsonConvert.DeserializeObject(_json);
}


However, when launched in web browser the process failed. I wonder if it has something to do with the path. Where should I put the "LangData_enUS.json" file? Or how should I specify the path :?:

Thank you.