Tuesday, November 3, 2009

To Read Line By Line of Text File in VB.net 2.0

In this Post I have shown the simple code snippet for reading a text file line by line.

Dim strFileName As String = String.Empty
Dim fs As FileStream = Nothing
Dim m_streamReader As StreamReader = Nothing
Dim strCompany As String = String.Empty

fs = New FileStream(strFilePath, FileMode.Open, FileAccess.Read)
m_streamReader = New StreamReader(fs)
m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin)

Do
strContent = m_streamReader.ReadLine()

Loop While (Not m_streamReader.EndOfStream)

No comments:

Post a Comment