Beispiel #1
0
        static void serialize(Classes.Character.Player playerToSerialize, string fileName)
        {
            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);

            formatter.Serialize(stream, playerToSerialize);
            stream.Close();
        }
Beispiel #2
0
        static Classes.Character.Player deserialize(string fileName)
        {
            IFormatter formatter = new BinaryFormatter();
            Stream     stream    = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);

            Classes.Character.Player deserializedPlayer = (Classes.Character.Player)formatter.Deserialize(stream);
            stream.Close();

            return(deserializedPlayer);
        }