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(); } }
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); }