Skip to content

Instantly share code, notes, and snippets.

@arafattehsin
Last active October 23, 2023 11:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arafattehsin/4fcf231455bacd258dfeda536fd2b4eb to your computer and use it in GitHub Desktop.
Save arafattehsin/4fcf231455bacd258dfeda536fd2b4eb to your computer and use it in GitHub Desktop.
public async Task<List<Country>> LoadCountries()
{
try
{
using var stream = await FileSystem.OpenAppPackageFileAsync("countries.json");
using var reader = new StreamReader(stream);
var contents = reader.ReadToEnd();
var countries = JsonSerializer.Deserialize<List<Country>>(contents);
return countries;
}
catch(Exception ex)
{
throw new Exception(ex.Message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment