Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BinaryFormatter bf = new BinaryFormatter();
- FileStream Archivo = File.OpenWrite(urlDatos + nombreArchivo);
- bf.Serialize(Archivo, user); //user es instancia de Usuario, este objeto lo recibo por parametro
- Archivo.Close();
- using (FileStream streamIn = File.OpenRead(urlDatos+nombreArchivo))
- {
- usuarios = new List<Usuario>();
- BinaryFormatter formatter = new BinaryFormatter();
- streamIn.Position = 0;
- while (streamIn.Position != streamIn.Length)
- {
- usuarios.Add((Usuario)formatter.Deserialize(streamIn));
- }
- return usuarios;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement