Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. private void btnRead_Click(object sender, System.EventArgs e)
  2. {
  3. OpenFileDialog ofd = new OpenFileDialog();
  4. ofd.ShowDialog();
  5. FileStream fs = new FileStream(ofd.FileName, FileMode.OpenOrCreate);
  6. StreamReader sr = new StreamReader(fs);
  7. int lineCount=0;
  8. while (sr.ReadLine()!=null)
  9. {
  10. lineCount++;
  11. }
  12. fs.Close();
  13. MessageBox.Show("There are " + lineCount + " lines in " + ofd.FileName);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement