Wednesday, December 15, 2010

WPF download and save image using VB.NET

Dim myWebClient As New WebClient()
        Dim strThumb As New Uri("http://www.somesite.com/image.jpg")
        Using stream As Stream = myWebClient.OpenRead(strThumb)
        
            Using bitmap As New System.Drawing.Bitmap(stream)
                'flush and close the stream
                stream.Flush()
                stream.Close()
            
                bitmap.Save(AppDomain.CurrentDomain.BaseDirectory + "Cache\test.jpg")
            End Using
        End Using

No comments:

Post a Comment