Code to read File Content

Virendradugar
Posted by Virendradugar under VB.NET category on | Views : 1819
Public Shared Function ReadFileContent(ByVal sFile As String) As String
Dim sFileContent As String = String.Empty

If File.Exists(sFile) Then
Dim srContent As StreamReader = File.OpenText(sFile)

Try
srContent = File.OpenText(sFile)
sFileContent = srContent.ReadToEnd()
Catch exp As Exception
Throw ex
Finally
If Not Nothing Is srContent Then
srContent.Close()
End If
End Try
End If
Return sFileContent
End Function

Comments or Responses

Login to post response