Hi all,
i need to backup a list filled with objects of this class:
This is my list class:Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace XML2 { public enum userLevel { Manager, Librarian, Reader }; [Serializable] public class Users { public string _username { get; set; } public string _password { get; set; } public userLevel _level { get; set; } public Users() { } public Users(string name, string password, userLevel level) { _username = name; _password = password; _level = level; } } }
When i execute it without the Enum it works fine but with it it crashes.Code:using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Xml.Serialization; using System.IO; namespace XML2 { [Serializable] public class userDB { List<Users> users = new List<Users>(); public userDB() { users.Add(new Users("Administrator", "12345678", userLevel.Manager)); users.Add(new Users("Librarian", "12345678", userLevel.Librarian)); users.Add(new Users("Reader", "12345678", userLevel.Reader)); save(); } public void save() { XmlSerializer serializer = new XmlSerializer(typeof(List<Users>)); using (FileStream fs = File.Open(@"users.xml", FileMode.Create)) { serializer.Serialize(fs, users); } } } }
is there any solution for this?
Thanx in advance.
I'm using VS2008




Reply With Quote