I have a xamarin app where I need to read from a json file I have added in the Asset folder.
This is how the folder tree is in the solution explorer.
The code being used to read this json file is called from the User class in the Model folder.
This is how I have tried to access this file.
string path = Path.Combine(Directory.GetCurrentDirectory(), "..", "Assets", "data", "User.json");
var assembly = typeof(User).GetType().Assembly;
var stream = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.{"User.json"}");
using (var reader = new StreamReader(stream))
{
string jsonString = await reader.ReadToEndAsync();
users = JsonConvert.DeserializeObject<List<User>>(jsonString);
}
The stream variable is null. Please help out.