Tuesday, February 2, 2010

Checks Image Exist at an URL

public static bool CheckImageExist(string strImageURL)
        {
            bool blnImageExist = true;
            System.Net.HttpWebRequest httpImageRequest = null;
            System.Net.HttpWebResponse httpImageResponse = null;

            // Sends the HttpWebRequest and waits for the response.
            try
            {
                httpImageRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(strImageURL);
                httpImageResponse = (System.Net.HttpWebResponse)httpImageRequest.GetResponse();
            }
            catch (Exception ex)
            {
                blnImageExist = false;
            }

            return blnImageExist;
        }

No comments:

Post a Comment