Saturday, 24 August 2013

Working with files in MonoGame and Android

Working with files in MonoGame and Android

So I made a game in XNA, and to get scores from a file I do something like
this...
private void GetScore()
{
if (File.Exists(scoreFilename))
{
using (StreamReader sr = new StreamReader(scoreFilename))
{
hiScore = Convert.ToInt16(sr.ReadLine());
}
}
else
{
FileStream fs = File.Create(scoreFilename);
fs.Close();
using (StreamWriter sw = new StreamWriter(scoreFilename))
{
sw.Write("0");
}
hiScore = 0;
}
}
This works on Windows, but how would I do this for Android?

No comments:

Post a Comment