vb.net Code:
<SecuritySafeCritical> _
Public Shared Function ReadAllLines(ByVal path As String) As String()
If (path Is Nothing) Then
Throw New ArgumentNullException("path")
End If
If (path.Length = 0) Then
Throw New ArgumentException(Environment.GetResourceString("Argument_EmptyPath"))
End If
Return File.InternalReadAllLines(path, Encoding.UTF8)
End Function
and here's the implementation of InternalReadAllLines that it calls:
vb.net Code:
Private Shared Function InternalReadAllLines(ByVal path As String, ByVal encoding As Encoding) As String()
Dim list As New List(Of String)
Using reader As StreamReader = New StreamReader(path, encoding)
Dim str As String
Do While (Not str = reader.ReadLine Is Nothing)
list.Add(str)
Loop
End Using
Return list.ToArray
End Function
As you can see, a StreamReader is created and ReadLine is called. It's just more convenient to make the one simple method call if you do want all the lines in the file but, if you don't, then it's more efficient to write a little bit more code and read only what you need.