WebClient Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there,

Can anyone tell me why this code appears to be throwing a WebException, and
also why the files are still downloading
try
{
imageData = webClient.DownloadData(total);
MemoryStream ms = new MemoryStream(imageData);
Bitmap b = new Bitmap(ms);
b.Save(@"C:\temp\IMAGE", ImageFormat.Tiff);
}
catch(Exception ex)
{
MessageBox.Show(ex.StackTrace);
}

the file IMAGE.tif is still saved, and it is also the correct file, im
gettin the following error

the remote server has returned an error: (404) Not Found
 
Thaynann said:
Can anyone tell me why this code appears to be throwing a WebException, and
also why the files are still downloading
try
{
imageData = webClient.DownloadData(total);
MemoryStream ms = new MemoryStream(imageData);
Bitmap b = new Bitmap(ms);
b.Save(@"C:\temp\IMAGE", ImageFormat.Tiff);
}
catch(Exception ex)
{
MessageBox.Show(ex.StackTrace);
}

the file IMAGE.tif is still saved, and it is also the correct file, im
gettin the following error

the remote server has returned an error: (404) Not Found

It seems very unlikely to me that your diagnosis is correct. Could you
post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Note that you should dispose of the bitmap after you're finished with
it (eg with a "using" statement).
 
Hi,


Sound very difficult to believe, you see, the only method that can throw
that exception is DownloadData , if it does so you don't get a return value

What you get in your stacktrace?

cheers,
 
Back
Top