This is the code snippet I use for loading and saving High scores in a WP7 app, tweak it to suit your needs. It could save millions of lives :D
private void LoadHighScore()
{
// open isolated storage, and load data from the savefile if it exists.
#if WINDOWS_PHONE
using (IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForApplication())
#else
using (IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForDomain())
#endif
{
if (savegameStorage.FileExists("guessthecard.txt"))
{
using (IsolatedStorageFileStream fs = savegameStorage.OpenFile("guessthecard.txt", System.IO.FileMode.Open))
{
if (fs != null)
{
// Reload the saved high-score data.
byte[] saveBytes = new byte[4];
int count = fs.Read(saveBytes, 0, 4);
if (count > 0)
{
highScore = System.BitConverter.ToInt32(saveBytes, 0);
}
}
}
}
}
}
// Save highscore
public async void UnloadContent()
{
// SAVE HIGHSCORE
// Save the game state (in this case, the high score).
#if WINDOWS_PHONE
IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForApplication();
#else
IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForDomain();
#endif
// open isolated storage, and write the savefile.
IsolatedStorageFileStream fs = null;
using (fs = savegameStorage.CreateFile("guessthecard.txt"))
{
if (fs != null)
{
// just overwrite the existing info for this example.
byte[] bytes = System.BitConverter.GetBytes(highScore);
fs.Write(bytes, 0, bytes.Length);
}
}
try
{
CardGuess item = new CardGuess { Text = highScore.ToString() };
await App.MobileService.GetTable<CardGuess>().InsertAsync(item);
}
catch(Exception e)
{
}
}