I am trying to download image from website, but it gives me error i.e. (The remote server returned an error: (502) Bad Gateway). I search a lot on internet but didn't get exact solution. This code is working on some website but on few website it is showing above error. Please check my below code...
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim filename As String = Application.StartupPath
If Not filename.EndsWith("\") Then filename &= "\"
txtLocalFile.Text = "D:\a.jpg" 'filename & " "
txtRemoteFile.Text = "http://ift.tt/1ErQ2Js"
End Sub
Private Sub btnDownload_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDownload.Click
Application.DoEvents()
Try
Dim web_client As WebClient = New WebClient
Dim wp = New WebProxy("proxy ip", proxy_port)
wp.Credentials = New NetworkCredential("uname", "password", "domainname")
web_client.Proxy = wp
web_client.DownloadFile(txtRemoteFile.Text, txtLocalFile.Text)
MessageBox.Show("Done")
Catch ex As Exception
End Try
End Sub
Can you please tell me which part of code is missing or i have to change..
Aucun commentaire:
Enregistrer un commentaire