Vb.net – 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.


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

Best Solution

This is the simplest way I know.

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

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."

Related Question