webclient download problem!!!
Posted
by
user472018
on Stack Overflow
See other posts from Stack Overflow
or by user472018
Published on 2010-12-27T13:46:40Z
Indexed on
2010/12/27
13:53 UTC
Read the original article
Hit count: 254
Hello all,
if this problem was discussed before,sorry for asking again..
I want to download an image from an url with using System.Net.WebClient class.
When i try to download an image (ie. google logo).it does not occur any errors,but some images are occurring errors.I dont understand why this errors.
how can i fix this problem?
my Code is:
WebClient client = new WebClient();
try
{
//Downloads the file from the given url to the given destination
client.DownloadFile(urltxt.Text, filetxt.Text);
return true;
}
catch (WebException w)
{
MessageBox.Show(w.ToString());
return false;
}
catch (System.Security.SecurityException)
{
MessageBox.Show("securityexeption");
return false;
}
catch (Exception)
{
MessageBox.Show("exception");
return false;
}
Errors are:
System.Net.WebException:The underlying connection was closed:An unexpected error occurred on a recieve.-->System.IO.IOException:Unable to read data from the transport connection:An existing connection was forcibly closed by the remote host.-->System.Net.Sockets.SocketException:An existing connection was forcibly closed by the remote host...bla bla
Thanks for your help.
© Stack Overflow or respective owner