public YearTop Copy() { YearTop retYear = null; BinaryFormatter serializer = new BinaryFormatter(); BinaryFormatter deserializer = new BinaryFormatter(); using (MemoryStream stream = new MemoryStream()) { serializer.Serialize(stream, this); stream.Position = 0; retYear = (YearTop)deserializer.Deserialize(stream); } return(retYear); }
static public YearTop LoadFromFile(string filepath) { YearTop jsonYear = null; if (File.Exists(filepath)) { Console.WriteLine("Reading saved file"); Stream openFileStream = File.OpenRead(filepath); BinaryFormatter deserializer = new BinaryFormatter(); jsonYear = (YearTop)deserializer.Deserialize(openFileStream); jsonYear.TimeLastLoaded = DateTime.Now; openFileStream.Close(); } return(jsonYear); }