Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Text;
  4. using System.Windows.Forms;
  5.  
  6. namespace WindowsFormsApp3
  7. {
  8. public partial class Form1 : Form
  9. {
  10. public Form1()
  11. {
  12. InitializeComponent();
  13. }
  14.  
  15. private void buttonReadFile_Click(object sender, EventArgs e)
  16. {
  17. try
  18. {
  19. /*
  20. Calculator c = new Calculator();
  21. Dog d = new Dog("A");
  22. Dog d = new Dog();
  23. */
  24.  
  25.  
  26. DialogResult result = ofd.ShowDialog();
  27. if (result == DialogResult.OK) // Test result.
  28. {
  29. using (StreamReader sr = new StreamReader(ofd.FileName))
  30. {
  31.  
  32. String line;
  33. int l = 0;
  34. while ((line = sr.ReadLine()) != null)
  35. {
  36. l++;
  37. textBoxReadFile.AppendText(l+"."+line);
  38. textBoxReadFile.AppendText(Environment.NewLine);
  39. }
  40. textBox1.Text = l.ToString();
  41. }
  42. }
  43. }
  44. catch (Exception ex)
  45. {
  46. MessageBox.Show(ex.Message);
  47. }
  48.  
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement