我想增加玩家的分数并检查高分,以便我将分数存储在文本文件中。我正在尝试下面的代码,但它抛出异常。
例外:值不在预期范围内。
public void storage()
{
var appstorage = IsolatedStorageFile.GetUserStoreForApplication();
String filename = "store.txt";
using (var file = appstorage.OpenFile(filename, FileMode.OpenOrCreate,FileAccess.ReadWrite))
{
using (var writer = new StreamWriter(file))
{
writer.Write(score);
}
using(var reader=new StreamReader(file))
{
playerscore =reader.ReadLine();
}
}
}