Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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)

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

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...