I'm not sure what is wrong with your code, but this works for me, perhaps you can refactor it:
WebRequest request = WebRequest.Create("http://www.dur.ac.uk/images/about/new/DurhamCastleCathedral.jpg");
request.Proxy.Credentials = CredentialCache.DefaultCredentials;
WebResponse response = request.GetResponse();
Image image = Image.FromStream(response.GetResponseStream());
image.Save(@"c:\foo.jpg", ImageFormat.Jpeg);
response.Close();
You should be able to read from the response stream into the output file stream directly, if you don't need the intermediate
Image
object. This will save memory, and might be quicker under certain circumstances.