I'm required to retrieve and save an image from a website to my local folder. The image type varies between .png, .jpg and .gif
I've tried using
string url = @"http://redsox.tcs.auckland.ac.nz/CSS/CSService.svc/";
string saveLoc = @"/project1/home_image";
using (var wc = new WebClient())
{
wc.DownloadFile(url, saveLoc);
}
but this saves the file 'home_image' in the folder without the extension. My question is how do you determine the extension? Is there a simple way to do this? Can one use the Content-Type of the HTTP request? If so, how do you do this?