public MainWindow() { InitializeComponent(); //Read from the test file string[] arrLines = System.IO.File.ReadAllLines(@"Users.txt"); //Split each line and create a person object foreach (string line in arrLines) { //Spit the line ito an array of parts string[] arrParts = line.Split(','); //save the parts into new object ClaPerson newPerson = new ClaPerson(); //call upon the create newPerson.createUser(arrParts[0], arrParts[1], arrParts[2]); //set the password newPerson.setPassword(arrParts[4]); //save into the datastore of people claDataStore.lstPeople.Add(newPerson); } }
private void btnCreate_Click(object sender, RoutedEventArgs e) { //instantiate a new person ClaPerson newPerson = new ClaPerson(); //Create person using base values newPerson.createUser(txtENumber.Text, txtFName.Text, txtSName.Text); //Add person to datastore claDataStore.lstPeople.Add(newPerson); //Save to txt file System.IO.File.AppendAllText(@"Users.txt", Environment.NewLine + newPerson.saveString()); //Close the window Close(); }