protected override async void OnNavigatedFrom(NavigationEventArgs e) { //auto-save if game not finished if (!game.isEnd()) { string fullName = UWPIO.SAVEDIR + "\\" + game.getTitle() + game.getAuthor() + ".json"; await UWPIO.createFile(fullName, saveToString(game)); } base.OnNavigatedFrom(e); }
async void updateGames() { Games = new ObservableCollection <SaveGameInfo>(); List <string> fileList = await UWPIO.listFiles(UWPIO.SAVEDIR); foreach (string f in fileList) { int l = f.Length; if (f.Substring(l - 5) == ".json" || f.Substring(l - 4) == ".agf") { string fname = UWPIO.SAVEDIR + "\\" + f; string content = await UWPIO.readFile(fname); ActiveGame ag = loadFromString(content); Games.Add(new SaveGameInfo(ag.getTitle(), ag.getAuthor(), await UWPIO.dateModifiedAsync(fname), ag)); } } updateProperty(nameof(Games)); }