Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsFormsApp3
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void buttonReadFile_Click(object sender, EventArgs e)
- {
- try
- {
- /*
- Calculator c = new Calculator();
- Dog d = new Dog("A");
- Dog d = new Dog();
- */
- DialogResult result = ofd.ShowDialog();
- if (result == DialogResult.OK) // Test result.
- {
- using (StreamReader sr = new StreamReader(ofd.FileName))
- {
- String line;
- int l = 0;
- while ((line = sr.ReadLine()) != null)
- {
- l++;
- textBoxReadFile.AppendText(l+"."+line);
- textBoxReadFile.AppendText(Environment.NewLine);
- }
- textBox1.Text = l.ToString();
- }
- }
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement