Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. using System.Runtime.Serialization.Formatters.Binary;
  2. using System.IO;
  3. [Serializable]
  4. public class UserPrefs
  5. {
  6. public string WindowColor;
  7. public int FontSize;
  8. }
  9. static class Program
  10. {
  11. [STAThread]
  12. static void Main()
  13. {
  14. UserPrefs userData = new UserPrefs();
  15. userData.WindowColor = "Yellow";
  16. userData.FontSize = 50;
  17. BinaryFormatter binFormat = new BinaryFormatter();
  18. // Сохранить объект в локальном файле.
  19. using (Stream fStream = new FileStream("user.xml",
  20. FileMode.Create, FileAccess.Write, FileShare.None))
  21. {
  22. binFormat.Serialize(fStream, userData);
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement