Reputation: 51
Im trying to find out how to save highscore data to the isolated storage on windows phone. I have searched numerous things and have found nothing working. Anyone know how I can do this?
Upvotes: 0
Views: 143
Reputation: 3185
The following answer was taken from this MSDN entry:
http://msdn.microsoft.com/en-us/library/ff604992.aspx
XNA Game Studio 4.0 Refresh does not provide access to writeable storage on Windows Phone. To access such storage, you'll need to use classes from the System.IO.IsolatedStorage namespace.
For Windows Phone projects, Visual Studio automatically adds the assembly containing System.IO.IsolatedStorage to your project. There is no need to add any additional references to your project.
Examples for writing data to the Isolated storage:
protected override void OnExiting(object sender, System.EventArgs args)
{
// Save the game state (in this case, the high score).
IsolatedStorageFile savegameStorage = IsolatedStorageFile.GetUserStoreForApplication();
// open isolated storage, and write the savefile.
IsolatedStorageFileStream fs = null;
using (fs = savegameStorage.CreateFile(SAVEFILENAME))
{
if (fs != null)
{
// just overwrite the existing info for this example.
byte[] bytes = System.BitConverter.GetBytes(highScore);
fs.Write(bytes, 0, bytes.Length);
}
}
base.OnExiting(sender, args);
}
Upvotes: 1