how to copy an image from a URL to a specific path

paulnamroud

Member
Joined
Nov 1, 2006
Messages
5
Programming Experience
5-10
Hi everyone,
I need your help.
I'm writing a Vb.Net application which should copy many images (images001.jpg, images002.jpg...) from an URL address (i.e http://mysite.com/images/images001.jpg).
I don't know how to copy each image from the URL address (i.e http://mysite.com/images/) to a network path (i.e \\MyNetwork\Images\).
I had already found on internet a code which allow me to check the existence of any image giving a URL address.
Can anyone tell me how to copy an image from a URL to a specific path ?
Thank you.
Paul

VB.NET:
Function ImageExiste(ByVal p_url As String) As Boolean
Dim xmlHttp
xmlHttp = CreateObject("Microsoft.xmlHttp")
xmlHttp.Open("GET", p_url, False)
xmlHttp.Send()
Select Case xmlHttp.status
Case 200 'found
ImageExiste = True
Case 404 'Not found
ImageExiste = False
Case Else 'Some other problem
ImageExiste = False
End Select
'ImageExiste = xmlHttp.Status
xmlHttp = Nothing
End Function
 
Last edited by a moderator:
Give this a shot:

Imports System.Net

VB.NET:
[SIZE=2][COLOR=#0000ff]
Dim[/COLOR][/SIZE][SIZE=2] client [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] WebClient
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strURL [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#800000]"http://www.mysite.com/myimage.jpg"
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strFilename [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = "YourPathInHere[/SIZE][SIZE=2][COLOR=#800000][URL="file://\\mypath\\myfolder\"]"[/URL][/COLOR][/SIZE]
[SIZE=2]client.DownloadFile(strURL, strFilename)
[/SIZE]
 
Back
Top