' this code would be on the page or control and be called on some kind of action (click etc)
Dim strFileContent As String = ReadFileToString(FileUpload.PostedFile.InputStream)
' function to return file content as string from the Stream (in this case is was an html file)
Private Shared Function ReadFileToString(ByVal streamFileContent As System.IO.Stream) As String
Try
' read the contents of the file into a string
Dim strFileContent As String = String.Empty
Using sr As IO.StreamReader = New IO.StreamReader(streamFileContent)
strFileContent = sr.ReadToEnd
End Using
Return strFileContent
Catch ex As Exception
Utilities.LogError(ex, "ParseHTML.vb.ReadFileToString")
Return String.Empty
End Try
End Function
No comments:
Post a Comment