Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. [Serializable]
  2. public class SCMng
  3. {
  4.  
  5. [XmlElement("SC")]
  6. public ObservableCollection<SC> SCCollection { get; set; }
  7.  
  8. [XmlIgnore]
  9. public SC SCPreview { get; set; }
  10.  
  11. public SCMng()
  12. {
  13. this.SCCollection = new ObservableCollection<SC>();
  14. this.SCPreview = new SC();
  15. }
  16.  
  17. public void SaveMD(string pPath)
  18. {
  19. Directory.CreateDirectory(Path.GetDirectoryName(pPath));
  20.  
  21. if (System.IO.File.Exists(pPath))
  22. System.IO.File.Delete(pPath);
  23.  
  24. var ser = new XmlSerializer(typeof(SCMng));
  25. using (var fs = new FileStream(pPath, FileMode.OpenOrCreate))
  26. ser.Serialize(fs, this);
  27. }
  28.  
  29. }
  30.  
  31. SCMng fooBar = new SCMng();
  32.  
  33. public void Save(){
  34. this.fooBar.SaveMD(AppDomain.CurrentDomain.BaseDirectory + @"new.xml");
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement