save images from url

前端 未结 4 1120
無奈伤痛
無奈伤痛 2021-01-13 19:27

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

For example : From www.domain.com/image.jpg to <

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-13 20:13

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

提交回复
热议问题