Hi everyone,
Could you giude me on the following topic please, or what topic does this come under?
Thanks
I would like to download files from a web site and place them on my local machine.
Printable View
Hi everyone,
Could you giude me on the following topic please, or what topic does this come under?
Thanks
I would like to download files from a web site and place them on my local machine.
Very basic code for downloading files :
VB Code:
Dim dl As New Net.WebClient dl.DownloadFile(-,-)
I am trying to download a file, and using the code above gives me a 407 error (Proxy Authentication Required). I can't download any files from any site, so it's not a password-related issue. Could it be something to do with the server at my end? Any ideas would be much appreciated.
Thanks,
Vulpes
Yes, you are using an authenticating proxy to connect to internet. This settings works for any program that tries to use the Internet Settigns of Windows, however some browsers like Netscape and Opera use their own settings.
To authenticate proxy you can use:
VB Code:
Dim dl As New Net.WebClient Dim wp As New Net.WebProxy("proxyserver", portnumber) Dim cr As New System.Net.NetworkCredential("username", "pass") wp.Credentials = cr Net.GlobalProxySelection.Select = wp dl.DownloadFile("url", "file")
Thanks Lunatic3 - just to clarify, "username", "pass" and "proxyserver" refer to my local domain settings?
Yes, but not necessarily. Sometimes to connect to special resources you need to connect through a proxy server that is not on your local domain. And also you can have a settings part in your program that lets user set the proxy server and then a pop up window that asks for username and password.
Thanks again for the help - I just managed to get it working about 5 minutes ago. Ironically the hardest part so far was finding out the name of the local proxy server :)
-Vulpes
There is a method that automatically deted the nondynamic proxy settings of Internet Explorer
VB Code:
Try Dim wp As New Net.WebProxy(Net.WebProxy.GetDefaultProxy.Address) MessageBox.Show(wp.Address.ToString) Catch ex As Exception 'Either no proxy or some other errors. End Try
Wow that'll save me some time - was wondering how I would make the program work for anyone. Thanks again :)
-Vulpes