Invalid character in a Base-64 string - help!
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
Re: Invalid character in a Base-64 string - help!
Hi,
Ultimately what are you trying to achieve here?
Does the url you are using point directly to an image?
In the code below
Code:
Dim b As Byte() = Convert.FromBase64String(content)
would you expect content at this point to be a Base64 encoded image?
Re: Invalid character in a Base-64 string - HELP
Hello,
If you set a breakpoint on that line, and add content to a watch window, what is it's value?
Gary
Re: Invalid character in a Base-64 string - help!
Duplicate threads merged.
Gary
Re: Invalid character in a Base-64 string - help!
The URL is pointed to a html page. Actually it will be an aspx page. Does this not work that way? I just saw the code and they said to use it to capture a webpage to an image. I've seen controls out there for this and I need to capture the page as an image where whatever the content is will be the size of the captured image. For example, I want to show a gridview control on an aspx page and capture that part as an image. Nothing else will be shown on the page anyways.
Thanks
Re: Invalid character in a Base-64 string - help!
Can you point us at the article/blog post that you are referring to?
Gary