This should work if I understand your question correctly:
private string GetFileNameFromUrl(string url)
{
if(string.IsNullOrEmpty(url))
return "image.jpg"; //or throw an ArgumentException
int sepIndex = url.LastIndexOf("/");
if(sepIndex == -1)
return "image.jpg"; //or throw an ArgumentException
return url.Substring(sepIndex);
}
Then you can use it like so:
string uri = "http://www.mywebsite.com/res/myimage.jpg";
WebClient client = new WebClient();
client.DownloadFile(uri, this.GetFileNameFromUrl(uri));
If you have no control over the url itself you might want to do some validation on it e.g. Regex.