sevenhalo said:is the html file on the local computer, or are you trying to scrape a site.
Dim strPath As String = "Full Path To File"
Dim strFile As System.IO.File
Dim strmRead As New System.IO.StreamReader(strFile.OpenRead(strPath))
Dim htmldata As String
htmldata = strmRead.ReadToEnd
sevenhalo said:If you just want to open it and read it into a string, this'll do it for you (assuming that the html file is on the computer running the app):
VB.NET:Dim strPath As String = "Full Path To File" Dim strFile As System.IO.File Dim strmRead As New System.IO.StreamReader(strFile.OpenRead(strPath)) Dim htmldata As String htmldata = strmRead.ReadToEnd
But it's a sloppy way of doing it. Not to mention, since you're not flushing the buffer; you'll deffinitely see a performance hit on larger files.
Dim strPath As String = "Path to file even, so much for being anonymous :)"
Dim strFile As System.IO.File
Dim strmRead As New System.IO.StreamReader(strFile.OpenRead(strPath))
Dim arr() As String
Dim cnt As Long
While strmRead.Peek > 0
ReDim Preserve arr(cnt)
arr(cnt) = strmRead.ReadLine
cnt += 1
If cnt Mod 50 = 0 Then
strmRead.BaseStream.Flush()
End If
End While
Dim strPath As String = "FilePath"
Dim strFile As System.IO.File
Dim strmRead As New System.IO.StreamReader(strFile.OpenRead(strPath))
Dim cnt As Long = 0
Dim arr(100) As String
While strmRead.Peek > 0
If (cnt Mod 100 = 0) And cnt > 0 Then
ReDim Preserve arr(cnt + 100)
End If
arr(cnt) = strmRead.ReadLine
cnt += 1
End While
ReDim preserve arr(cnt)