Here is what I am using right now. Any criticisms?
public class Image
{
public static bool Verifies(string url)
{
if (url == null)
{
throw new ArgumentNullException("url");
}
Uri address;
if (!Uri.TryCreate(url, UriKind.Absolute, out address))
{
return false;
}
using (var downloader = new WebClient())
{
try
{
var image = new Bitmap(downloader.OpenRead(address));
}
catch (Exception ex)
{
if (
ex is WebException ||
ex is ArgumentException)
{
return false;
}
else
{
throw;
}
}
}
return true;
}
}
core source
share