public void LoadFromFile(string loadFileName, ref Sprite sprite) { if (File.Exists(loadFileName)) { Stream TestFileStream = File.OpenRead(loadFileName); BinaryFormatter deserializer = new BinaryFormatter(); Sprite.SpriteSave spriteSave = (Sprite.SpriteSave)deserializer.Deserialize(TestFileStream); sprite.Loadsprite(spriteSave); TestFileStream.Close(); } }
public void SaveToFile(string saveFileName, Sprite sprite) { if (sprite != null) { Stream saveFileStream = File.Create(saveFileName); BinaryFormatter serializer = new BinaryFormatter(); Sprite.SpriteSave spriteSave = sprite.SaveSprite(); serializer.Serialize(saveFileStream, spriteSave); saveFileStream.Close(); } }