Visual Basic .net count number of lines in a text file

Hi
How do I count hte number of lines in a text file with visual basic .net (2010)
LVL 1
sykotexAsked:
Who is Participating?
 
Rajar AhmedConsultantCommented:
try this
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim FSO = CreateObject("Scripting.FileSystemObject")
        Dim file = FSO.OpenTextFile("test.txt", 1) ' Give Corect Path Here
        File.ReadAll()
        Label1.Text = "Number Of Line = " & file.line.ToString()
End Sub

Open in new window

0
 
CodeCruiserCommented:
Another approach

IO.File.ReadAllLines("path").Count

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.