Here is a working copy of what I found to work for what I needed in my VB.Net Project.
Private Sub buttonExecuteScript_Click(sender As Object, e As EventArgs) Handles buttonExecuteScript.Click
Me.richTextBoxScriptHeader.Clear()
fullFileName = strFilePath
If Not String.IsNullOrEmpty(fullFileName) Then
Dim commentText As String = ExtractStringFromFile(fullFileName, "<#", "#>")
Me.richTextBoxScriptHeader.Text = commentText
End If
End Sub
Private Function ExtractStringFromFile(ByVal fullFileName As String, ByVal startMarker As String, ByVal endMarker As String) As String
Dim result As String = String.Empty
If Not File.Exists(strFilePath) Then
Msgbox("The passed filename does not exist.")
End If
Dim fileText As String = File.ReadAllText(strFilePath)
Dim startMarkerPosition As Integer = fileText.IndexOf(startMarker) + startMarker.Length
Dim endMarkerPosition As Integer = fileText.IndexOf(endMarker)
If endMarkerPosition > startMarkerPosition Then
result = fileText.Substring(startMarkerPosition, endMarkerPosition - startMarkerPosition)
End If
Return result
End Function