Results 1 to 1 of 1

Thread: Help with translating straight VB.net code to ASP.NET using VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2005
    Posts
    2

    Help with translating straight VB.net code to ASP.NET using VB

    Greetings,
    The following code works fine in a Windows app written in VB.Net, however it chokes in ASP.net written in VB:

    Function GetImageFromURL(ByVal url As String) As Byte()
    Dim wr As HttpWebRequest = _
    DirectCast(WebRequest.Create(url), HttpWebRequest)
    Dim wresponse As HttpWebResponse = _
    DirectCast(wr.GetResponse, HttpWebResponse)
    Dim responseStream As Stream = wresponse.GetResponseStream
    Dim br As BinaryReader = New BinaryReader(responseStream)
    Dim bytesize As Long = wresponse.ContentLength
    Return br.ReadBytes(bytesize)
    End Function

    Private Sub Button1_Click(ByVal sender As System.Object, _
    ByVal e As System.EventArgs) Handles Button1.Click
    Dim img As New Bitmap( _
    New IO.MemoryStream( _
    GetImageFromURL( _
    "http://yada.com/test.bmp") _
    ))
    img.save("c:\file.bmp")
    End Sub

    It seems to choke on the following:

    Dim img As New Bitmap( _
    New IO.MemoryStream( _
    GetImageFromURL( _
    "http://yada.com/test.bmp") _
    ))
    with the error of:
    [ArugumentExecption: Invalid parameters used.]
    System.Drawing.Bitmap..ctor(Stream stream)

    Any suggestions?

    Thanks
    Last edited by DerBiscuitKopf; Feb 23rd, 2005 at 01:03 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width