public static void Guardar(Partida partida) { using (Stream stream = File.Open(@"..\..\data\DataPartida.bin", FileMode.Create)) { List <string> partidas = partida.GetDatosPartida(); BinaryFormatter bin = new BinaryFormatter(); bin.Serialize(stream, partidas); stream.Close(); } }
public static void Cargar(Partida partida) { using (Stream stream = File.Open(@"..\..\data\DataPartida.bin", FileMode.Open)) { BinaryFormatter bin = new BinaryFormatter(); List <string> partidaActual = (List <string>)bin.Deserialize(stream); foreach (string s in partida.GetDatosPartida()) { partidaActual.Add(s); } } }