/// <summary> /// Save the high score data to an XML file /// </summary> /// <param name="data"></param> public static void SaveHighScoreData(HighScoreData data) { XmlSerializer ser = new XmlSerializer(typeof(HighScoreData)); TextWriter writer = new StreamWriter("Content/XML/HighScores.xml"); ser.Serialize(writer, data); writer.Close(); }
/// <summary> /// Read the high score data /// </summary> /// <returns></returns> public static HighScoreData GetHighScoreData() { HighScoreData data = null; StreamReader reader = new StreamReader("Content/XML/HighScores.xml"); try { data = (HighScoreData) new XmlSerializer(typeof(HighScoreData)).Deserialize(reader.BaseStream); } catch (Exception e) { //for debugging only Console.WriteLine("Exception Message: " + e.Message); } finally { reader.Close(); } return(data); }