using System; using System.Collections.Generic; using System.Text; using Microsoft.Xna.Framework.Storage; using System.IO; using System.Xml.Serialization; namespace DarkWynter.Engine.HighScores { /// /// This class provides a way to save a list of HighScores /// class SaveScore { private String file; private String path; /// /// Constuctor that takes the path and file with extension /// /// /// public SaveScore(String path, String file) { this.path = path; this.file = file; }//end constructor /// /// Saves the List as a serialized XML /// /// public void Save(List scores) { string fileName = Path.Combine(path, file); // Open the file, creating it if necessary FileStream stream = File.Open(fileName, FileMode.OpenOrCreate); // Convert the object to XML data and put it in the stream XmlSerializer serializer = new XmlSerializer(typeof(List)); serializer.Serialize(stream, scores); // Close the file stream.Close(); }//end save }//end class }//end namespace