Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2016
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. private void button2_Click(object sender, EventArgs e)
  2. {
  3. Form2 form2 = new Form2();
  4. form2.Show();
  5.  
  6. }
  7.  
  8. private void button1_Click(object sender, EventArgs e)
  9. {
  10. try
  11. {
  12. var sr = new System.IO.StreamReader("C\" + textBox1.Text + "\login.ID");
  13. username = sr.ReadLine();
  14. password = sr.ReadLine();
  15. sr.Close();
  16.  
  17. if (username == textBox1.Text && password == textBox2.Text)
  18. MessageBox.Show("Log-in Successfull", "Success!");
  19. else
  20. MessageBox.Show("Username or password is wrong! ","Error!");
  21.  
  22. }
  23. catch (System.IO.DirectoryNotFoundException )
  24. {
  25. MessageBox.Show("The user doesn't exist!", "Error!");
  26.  
  27. }
  28. }
  29. }
  30.  
  31. public partial class Form2 : Form
  32. {
  33. public Form2()
  34. {
  35. InitializeComponent();
  36. }
  37.  
  38. private void button2_Click(object sender, EventArgs e)
  39. {
  40. Form2 form2 = new Form2();
  41. form2.Hide();
  42.  
  43. }
  44.  
  45. private void button1_Click(object sender, EventArgs e)
  46. {
  47. try
  48. {
  49. var sw = new System.IO.StreamWriter ("C\" + textBox1.Text + "\login.ID");
  50. sw.Write(textBox1.Text + "n" + textBox2.Text);
  51. sw.Close();
  52.  
  53. }
  54. catch(System.IO.DriveNotFoundException )
  55.  
  56. {
  57. System.IO.Directory.CreateDirectory("C:\" + textBox1.Text);
  58. var sw = new System.IO.StreamWriter("C\" + textBox1.Text + "\login.ID");
  59. sw.Write(textBox1.Text + "n" + textBox2.Text);
  60. sw.Close();
  61. }
  62.  
  63.  
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement