private void button1_Click(object sender, EventArgs e) { if (!File.Exists(Application.StartupPath + "\\data\\" + textBox1.Text + ".txt")) { // File.Create(Application.StartupPath + "\\data\\" + textBox1.Text + ".txt"); StreamWriter sw = new StreamWriter(Application.StartupPath + "\\data\\" + textBox1.Text + ".txt"); sw.WriteLine(textBox5.Text); sw.WriteLine(textBox1.Text); sw.WriteLine(textBox2.Text); sw.WriteLine(textBox6.Text); sw.WriteLine(textBox4.Text); sw.WriteLine(textBox3.Text); sw.Close(); MessageBox.Show("Cearte Account Successfully", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("This Account is already exist", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); this.Close(); } this.Visible = false; acc_frm frm = new acc_frm(textBox1.Text); frm.ShowDialog(); }
private void button1_Click(object sender, EventArgs e) { string line = " "; bool flag = false; if (File.Exists(Application.StartupPath + "\\data\\" + textBox1.Text + ".txt")) { StreamReader sr = new StreamReader(Application.StartupPath + "\\data\\" + textBox1.Text + ".txt"); while (line != null) { line = sr.ReadLine(); if (line == textBox2.Text) { flag = true; } } if (flag == true) { this.Visible = false; acc_frm frm = new acc_frm(textBox1.Text); frm.ShowDialog(); sr.Close(); } else { MessageBox.Show("Invalid Password", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("This Account is not exist\n 1-write correct name \n 2-Make a new account", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }