我试图找出如何将高分数据保存到windows上的隔离存储中。我搜寻了无数的东西,却发现什么也没有用。有人知道我是怎么做到的吗?
发布于 2014-04-12 10:53:26
以下答案取自此MSDN条目:
http://msdn.microsoft.com/en-us/library/ff604992.aspx
XNAGameStudio4.0Refresh不提供对Windows上可写存储的访问。要访问这样的存储,您需要使用System.IO.IsolatedStorage命名空间中的类。 对于Windows项目,Visual会自动将包含System.IO.IsolatedStorage的程序集添加到项目中。不需要向项目添加任何其他引用。
将数据写入隔离存储的示例:
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);
}https://stackoverflow.com/questions/23011753
复制相似问题