Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. BinaryFormatter bf = new BinaryFormatter();
  2. FileStream Archivo = File.OpenWrite(urlDatos + nombreArchivo);
  3. bf.Serialize(Archivo, user); //user es instancia de Usuario, este objeto lo recibo por parametro
  4. Archivo.Close();
  5.  
  6. using (FileStream streamIn = File.OpenRead(urlDatos+nombreArchivo))
  7. {
  8. usuarios = new List<Usuario>();
  9. BinaryFormatter formatter = new BinaryFormatter();
  10. streamIn.Position = 0;
  11. while (streamIn.Position != streamIn.Length)
  12. {
  13. usuarios.Add((Usuario)formatter.Deserialize(streamIn));
  14. }
  15. return usuarios;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement