private void button2_Click(object sender, EventArgs e) { lat = t21.Text + "-" + t22.Text + "-" + t23.Text + "-" + t24.Text + "-" + t25.Text + "-" + t26.Text + "-" + t27.Text + "-" + t28.Text; try { string str = File.ReadAllText("test.txt"); str = str.Replace(old, lat); File.WriteAllText("test.txt", str); MessageBox.Show("records updated"); this.Hide(); update u = new update(); u.Show(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void updateToolStripMenuItem1_Click(object sender, EventArgs e) { StreamReader sr = new StreamReader("index.txt"); { string app; while ((app = sr.ReadLine()) != null) { string[] a = app.Split('-'); { foreach (string word in a) { if (a[0] == t1.Text) { flag = 'y'; break; } else { flag = 'n'; } } } } if (flag == 'y') { ap = t1.Text; this.Hide(); update f = new update(); f.Show(); } else { MessageBox.Show("invalid player", "alert", MessageBoxButtons.OK, MessageBoxIcon.Information); } sr.Close(); } }