Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

save images from url

Is it possible to save images using Visual Basic 2008 from URL to my PC?

For example : From www.domain.com/image.jpg to C:\folder\image.jpg

P.S: I need simpliest example of the code, then I will edit is as I need.

Thanks.

Update : I want to know when the code have finished downloading of the image.

like image 564
John Avatar asked Mar 13 '12 17:03

John


2 Answers

This is the simplest way I know.

Dim Client as new WebClient
Client.DownloadFile(Source, Destination)
Client.Dispose

This is superior to using the My.Computer.Network.DownloadFile method per Microsoft's documentation

"The DownloadFile method does not send optional HTTP headers. Some servers may return 500 (Internal Server Error) if the optional user agent header is missing. To send optional headers, you must construct a request using the WebClient class."

like image 198
UnhandledExcepSean Avatar answered Oct 11 '22 12:10

UnhandledExcepSean


There's a simpler way:

My.Computer.Network.DownloadFile(Source, Desination)
like image 28
user3102516 Avatar answered Oct 11 '22 11:10

user3102516