I have JSON file in /resources/raw but when im trying to load i have error: System.IO.FileNotFoundException: 'Could not find file '/drinks.json'.' Code:
string drinksJsonData = File.ReadAllText("drinks.json");
var drinks = JsonSerializer.Deserialize<List<drinksclass>>(drinksJsonData);
if(drinks != null)
{
foreach(var drink in drinks)
{
await DisplayAlert("ALERT", "WORKING", "OK");
}
}
I have <MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
and <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
in .csproj. I also tried change build settings but its still not working.