예제 #1
0
        public void CreateFile()
        {
            // Create dummy data to save.
            HiScoreData data = new HiScoreData();
            data.AllTimeKills = 0;
            data.HighestWave = 0;
            data.HighestWaveKills = 0;

            SaveData(data);
        }
예제 #2
0
        public void CreateFile()
        {
            // Create dummy data to save.
            HiScoreData data = new HiScoreData();

            data.AllTimeKills     = 0;
            data.HighestWave      = 0;
            data.HighestWaveKills = 0;

            SaveData(data);
        }
예제 #3
0
        public void SaveData(HiScoreData data)
        {
            // Get the path of the save game
            string fullPath = "hiscores.dat";


            // Open the file, creating it if necessary
            FileStream stream = File.Open(fullPath, FileMode.Create);

            try
            {
                // Convert the object to XML data and put it in the stream
                XmlSerializer serializer = new XmlSerializer(typeof(HiScoreData));
                serializer.Serialize(stream, data);
            }
            finally
            {
                // Close the file
                stream.Close();
            }
        }
예제 #4
0
        public void SaveData(HiScoreData data)
        {
            // Get the path of the save game
            string fullPath = "hiscores.dat";


            // Open the file, creating it if necessary
            FileStream stream = File.Open(fullPath, FileMode.Create);
            try
            {
                // Convert the object to XML data and put it in the stream
                XmlSerializer serializer = new XmlSerializer(typeof(HiScoreData));
                serializer.Serialize(stream, data);
            }
            finally
            {
                // Close the file
                stream.Close();
            }
        
        }