This blog is moved to
http://amalhashim.wordpress.com

Thursday, August 27, 2009

Check a URL exist or not using C#

static bool CheckURL(String url)
{
if(String.IsNullOrEmpty(url))
return false;

WebRequest request = WebRequest.Create(url);

try
{
HttpWebResponse res = request.GetResponse() as HttpWebResponse;

if (res.StatusDescription == "OK")
return true;
}
catch
{
}

return false;
}

No comments: