Solving development problems  |  About this blog

Archive for the ‘check if image exists’ tag

Check if image (url) exists in ASP.NET

HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("url");
request.Method = "HEAD";

bool exists;
try
{
    request.GetResponse();
    exists = true;
}
catch
{
   exists = false;
}

Written by Avivo

August 14th, 2009 at 11:07 am