Exemple #1
0
        /// <summary>
        /// Saves the highscores.
        /// </summary>
        /// <param name="HighScore">list of highscores</param>
        private void SaveXboxHighScores(List<int> HighScore)
        {
            HighscoreData highscores = new HighscoreData();
            highscores.highscores = HighScore;

            if (storageDevice != null && storageDevice.IsConnected)
            {
                IAsyncResult result = storageDevice.BeginOpenContainer(CONTAINER_NAME, null, null);
                result.AsyncWaitHandle.WaitOne();
                StorageContainer container = storageDevice.EndOpenContainer(result);

                if (container.FileExists(HIGHSCORE_FILE))//if that file already exists
                {
                    container.DeleteFile(HIGHSCORE_FILE);//delete existing file
                }

                Stream stream = container.CreateFile(HIGHSCORE_FILE);//create file

                XmlSerializer serializer = new XmlSerializer(typeof(HighscoreData));
                serializer.Serialize(stream, highscores);

                stream.Close();//close the file
                container.Dispose();//disposing container commits changes to device
            }
        }
Exemple #2
0
        /// <summary>
        /// Saves the highscores.
        /// </summary>
        /// <param name="HighScore">list of highscores</param>
        private void SaveWindowsHighScores(List<int> HighScore)
        {
            HighscoreData highscores = new HighscoreData();
            highscores.highscores = HighScore;

            //if the path isn't null
            if (completePath != null)
            {
                using (var stream = new FileStream(completePathHighScore, FileMode.Create))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(HighscoreData));
                    serializer.Serialize(stream, highscores);
                }
            }
        }