I know this should be a basic question but I am hitting a brick wall. I am looking to go to a URL/URI download the resulting string as if I had opened a file and then get it out into a String variable.
I have been stuffing about with IO.Stream and Net.httpxxx but haven't managed to get the elements to line up in the right way.
I get "the given path's format is not supported" from opening the page in the standard stream, because it's not in the local file system ... that bit i understand, the bit I don't get is ... how do I achieve the equivelent of:
Public Function GetWebPageAsString(pURL As String) As String
Dim lStream As IO.StreamReader = New System.IO.StreamReader(pURL)
Return lStream.ReadToEnd
End Function
WebClient.OpenRead() might be what you're looking for.
Sample from the MSDN page linked above:
This function downloads any URI to a file. You could easily adapt it to put it into a string var:
The short answer, in C#, looks like