![]() Private void btnSave_Click( object sender, EventArgs e) no selection ? if (selection = null) return Object selection = listBox1.SelectedItem Private void btnDelete_Click( object sender, EventArgs e) already have this User name ? if (TheUsers.Contains(text)) return no valid entry ? if ( string.IsNullOrWhiteSpace(text)) return Private void btnAdd_Click( object sender, EventArgs e) Private void Form1_Load( object sender, EventArgs e) } Here's how you would serialize and de-serialize this class in the "main Form:" MessageBox.Show( " file read successfully") Throw new InvalidDataContractException( " Can't read file at: " + theUsers.FileLocation) Result = (Users) theSerializer.ReadObject(stream) Using (FileStream stream = new FileStream(theUsers.FileLocation, FileMode.Open)) lazy load if (theSerializer = null) theSerializer = new DataContractSerializer( typeof(Users)) Public static Users DeSerialize(Users theUsers) MessageBox.Show( " file successfully saved") Throw new InvalidDataContractException( " Can't save file to: " + theUsers.FileLocation) TheSerializer.WriteObject(stream, theUsers) ![]() ![]() Using (FileStream stream = new FileStream(theUsers.FileLocation, FileMode.Create)) If(theSerializer = null) theSerializer = new DataContractSerializer( typeof(Users)) Public static void Serialize(Users theUsers) ![]() Private static DataContractSerializer theSerializer įileLocation = Environment.GetFolderPath() įileLocation = Path.Combine(FileLocation, DefaultUsersFile.xml") ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |