c3b12 Posted September 16, 2004 Posted September 16, 2004 Can somebody help me on this issue? How to download a file with WebRequest and GetResponse when your are using (compagny security policy) an automatic configuration script (http://xxxx.yy:8080/cfg) to access Internet. (It works with the Wininet API functions but I'm looking for managed code) Quote
Administrators PlausiblyDamp Posted September 17, 2004 Administrators Posted September 17, 2004 Are you trying to download a specific file or just the ability to download any file from the internet? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
c3b12 Posted September 21, 2004 Author Posted September 21, 2004 Are you trying to download a specific file or just the ability to download any file from the internet? The tool I'm writing must have the ability to download any file from the Internet and save it. Quote
Administrators PlausiblyDamp Posted September 21, 2004 Administrators Posted September 21, 2004 Have you looked at the WebClient class? Dim w As New System.Net.WebClient w.DownloadFile(, ) Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
c3b12 Posted September 22, 2004 Author Posted September 22, 2004 Have you looked at the WebClient class? Dim w As New System.Net.WebClient w.DownloadFile(<url to downlaod from>, <path to save to>) Yes I've tried this. Here is my original code: Dim hwrRequête As HttpWebRequest Dim hwrRéponse As HttpWebResponse Dim hwrFlux As Stream Dim fsrFlux As FileStream Dim octTampon(999) As Byte Dim intLecture As Integer fsrFlux = New FileStream(m_strFichierCible, FileMode.Create) hwrRequête = CType(WebRequest.Create(m_strURL), HttpWebRequest) hwrRéponse = CType(hwrRequête.GetResponse, HttpWebResponse) hwrFlux = hwrRequête.GetResponse.GetResponseStream Do intLecture = hwrFlux.Read(octTampon, 0, 1000) fsrFlux.Write(octTampon, 0, intLecture) Loop Until intLecture = 0 If Not hwrFlux Is Nothing Then hwrFlux.Close() If Not fsrFlux Is Nothing Then fsrFlux.Close() I now know that I have a Proxy to go through. The exception message I got is the following: "The underlying connection was closed: the remote name could not be resolved" My pb is that I don't know the name of the proxy. Instead I have to support an automatic configuration script. If I read the Internet Lan Settings, I have: http://xxxx.yy:8080/cfg as the script. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.