all groups > dotnet remoting > july 2006 >
You're in the

dotnet remoting

group:

WebClient class is throwing exception


WebClient class is throwing exception Deepson Thomas
7/3/2006 4:28:01 AM
dotnet remoting:
Hi,

Iam trying to use WebClient class under system.net namespace to download
files from internet via http. For that iam using DownloadFile method. But
when ever iam trying to download any file iam getting the error “"The
underlying connection was closed: Unable to connect to the remote server”. My
computer is behind proxy. If iam trying to open this image via browser then
it is working.

I am pasting my code below.

string remoteUri = "http://www.deepson.com/images/";
string fileName = "uc2_large08.jpg", myStringWebResource = null;


WebClient myWebClient = new WebClient();
myStringWebResource = remoteUri + fileName;
Response.Write("<hr>Downloading File "+ fileName + " from "+
myStringWebResource );


myWebClient.DownloadFile(myStringWebResource,"C:\\inetpub\\wwwroot\\TestWebApp\\Downloaded\\"+fileName);

Response.Write("<hr>Successfully Downloaded File "+ fileName +" from "+
myStringWebResource);

When I am executing this code the file is created with 0 KB size but when
the error comes it is deleted automatically.

--
Deepson Thomas
Re: WebClient class is throwing exception Dave Sexton
7/4/2006 5:27:28 PM
Hi Deepson,

Try setting the WebClient.Proxy property to a new WebProxy instance
configured to meet your needs.

HTH

[quoted text, click to view]

AddThis Social Bookmark Button