4,152 questions
You need to add the file to your solution. Then make sure the file Build Action is MauiAsset.
Then you can use the file as the following , the filename is a constant in this case.
public async static Task<string> GetHistTeams()
{
string txt;
string mainDir = FileSystem.Current.AppDataDirectory;
var fullpath = Path.Combine(mainDir, "theTeams.json");
try
{
Stream fileStream = await FileSystem.Current.OpenAppPackageFileAsync("theTeams.json");
StreamReader reader = new StreamReader(fileStream);
txt = reader.ReadToEnd();
}
catch (Exception e)
{
var i = 1;
return string.Empty;
}
return txt;
}