-3
所以即时制作这个记忆游戏,即时尝试添加记分牌,我想写入数据到一个txt文件使用JSON。我已经完成了所有这些工作,但现在我遇到了一个小问题,每次运行我的程序时,我的txt文件中的现有数据都会被新数据覆盖。JSON保留现有的内容,同时写入新的(txt文件)
这里是我使用的代码:
public static void Score(String gamescore, string loginname)
{
List<Highscore> Myhighscores = new List<Highscore>();
Myhighscores.Add(new Highscore { Score = gamescore, Name = loginname });
string Jstr = JsonConvert.SerializeObject(Myhighscores);
File.WriteAllText(@"c:\temp\hs.txt", Jstr);
}
没有人知道我可以保留现有数据,并写入新的数据转换成txt文件?
为什么标签jQuery? –
cus我从jquery获取所有数据,但我想这对这个问题并不重要 –