private void button1_Click(object sender, EventArgs e) { mainBackend mb = new mainBackend(); String localLocation = Directory.GetCurrentDirectory() + "//Registrations"; if (String.IsNullOrEmpty(nameVal.Text)) { ; } { bool found = false; String userName = nameVal.Text + " " + surnameVal.Text; String locatedFile = ""; string[] files = new DirectoryInfo(localLocation).GetFiles().Select(o => o.Name).ToArray(); for (int i = 0; i < files.Length; i++) { String nameTest = files[i].Substring(0, files[i].Length - 3); if (userName.ToLower().Equals(nameTest.ToLower())) { found = true; localLocation = localLocation + "//" + nameTest + ".db"; break; } } if (found == true) { string text = System.IO.File.ReadAllText(localLocation); string[] datafile = mb.Decrypt(text).Split('♥'); if (datafile[4].Equals("Vote") || datafile[4].Equals("Both")) { if (datafile[3].Equals(idVal.Text.ToString().Trim())) { using (StreamWriter writetext = new StreamWriter("temp.db")) { writetext.WriteLine(text); } MainVotingSection mvs = new MainVotingSection(); mvs.Show(); this.Hide(); } else { MessageBox.Show("You are not authenticated to vote, Sorry!", "Error"); this.Hide(); this.Show(); } } else { MessageBox.Show("You are not allowed to vote, Sorry!" + datafile[0] + datafile[1] + datafile[2] + datafile[3] + datafile[4], "Error"); this.Hide(); this.Show(); } } else { MessageBox.Show("We didnt find you in the system, sorry about that!", "Error"); this.Hide(); this.Show(); } } }