Copying a jpg from a http web page using C#

  • Thread starter Thread starter Duncan Winn
  • Start date Start date
D

Duncan Winn

Is there any way of accessing and copying a JPG from a web page using C#.

I have tried using WebRequest but I don't know what to do this the
WebResponse, and I have
tried using WebClient but I cet a proxey error?

Any suggestions.
 
You should look into System.Web.HttpRequest. Construct and post a request
and process the response appropriately.

-vJ
 
Thanks,

But when I try 'using System.Web;' The compiler complains that it can't
find it?

Any suggestions?
 
Duncan Winn said:
Thanks,

But when I try 'using System.Web;' The compiler complains that it can't
find it?

Any suggestions?

references --> right click --> add refrerence --> system.web.dll or
something like that
 
Thanks, that worked, although I am a bit unsure of what to do next?

i.e. How do I construct and post a request
and process the response appropriately.

In order to copy a jpg from a wec page?
 
void GetImage()
{
System.Net.WebRequest request =
System.Net.WebRequest.Create("http://www.microsoft.com/homepage/gif/bnr-micr
osoft.gif");
System.Net.WebResponse response = request.GetResponse();

System.Drawing.Bitmap bmp = new
System.Drawing.Bitmap(response.GetResponseStream());
bmp.Save("c:\\msft.gif", System.Drawing.Imaging.ImageFormat.Gif);
bmp.Dispose();
response.Close();
}

-vJ
 
Thanks a million, that is really healpfull. Just out of interest do you
know of any good books on this sort of subject?

Best regards,

Duncan.
 
Back
Top