Hi everyone,

I found this code on this site in another thread and tried it. I am passing a string of a web url such as "http://www.website.com" and it gives me this error. How can I pass in the URL without this error?

Code:

Code:
    Private Sub saveURLToImage(ByVal url As String)
        If Not String.IsNullOrEmpty(url) Then

            Dim content As String = ""
            Dim webRequest__1 As System.Net.WebRequest = WebRequest.Create(url)
            Dim webResponse As System.Net.WebResponse = webRequest__1.GetResponse()
            Dim sr As System.IO.StreamReader = New StreamReader(webResponse.GetResponseStream(), System.Text.Encoding.GetEncoding("UTF-8"))
            content = sr.ReadToEnd()
            'save to file
            Dim b As Byte() = Convert.FromBase64String(content)
            Dim ms As New System.IO.MemoryStream(b)
            Dim img As System.Drawing.Image = System.Drawing.Image.FromStream(ms)
            img.Save("e:\default\wwwroot\site\images\report22.jpg", System.Drawing.Imaging.ImageFormat.Jpeg)
            img.Dispose()
            ms.Close()
        End If
    End Sub