.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
2,861 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi all. I need to debug text from a text file and the emulator don't open a file from my computer so I can debug my app exit with null reference exception and I want to locate the location. how I can do that with the emulator. Thank you very much
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;
}