Пример #1
0
        public static void SaveHighScores(HighScores data, string filename)
        {
            #if XBOX
            return;
            #endif

            string fullpath = @"Content\" + filename;

            FileStream stream = File.Open(fullpath, FileMode.OpenOrCreate);
            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(HighScores));
                serializer.Serialize(stream, data);
            }
            finally
            {
                stream.Close();
            }
        }
Пример #2
0
        public static HighScores LoadHighScores(string filename)
        {
            HighScores data = new HighScores();

            string fullpath = @"Content\" + filename;

            FileStream stream = File.Open(fullpath, FileMode.OpenOrCreate, FileAccess.Read);

            try
            {
                XmlSerializer serializer = new XmlSerializer(typeof(HighScores));
                data = (HighScores)serializer.Deserialize(stream);
            }
            catch (InvalidOperationException e)
            {
            }
            finally
            {
                stream.Close();
            }

            return(data);
        }