LoadFromFile

Module m_Extensions
<Extension()> Public Function LoadFromFile(ByVal Expression As String, ByVal Filename As String) As Exception
        Try
            Dim oRead As New System.IO.StreamReader(Filename, System.Text.Encoding.Default)
            Expression = oRead.ReadToEnd
            oRead.Close()
            Return Nothing
        Catch ex As Exception
            Return ex
        End Try
    End Function
End Module
Example:
Dim Text As String
Dim E As Exception = Text.LoadFromFile("C:\data.txt")
If E IsNot Nothing Then
   MessageBox.Show(E.ToString)
End If

Description

Read and assign a file content to String Variable

Details

Double click on the code to select all.

 

;