C# 判断网站是否能访问或者断链

参考网站:http://www.cnblogs.com/junny/archive/2012/10/30/2745978.html

public bool CheckUrlVisit(string url)
{
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
HttpWebResponse resp = (HttpWebResponse)req.GetResponse();
if (resp.StatusCode == HttpStatusCode.OK)
{
          resp.Close(); 
return true;
}
}
catch (WebException webex)
{
return false;
} return false; }
上一篇:33.Odoo产品分析 (四) – 工具板块(4) – 问题追踪及群发邮件营销(1)


下一篇:【转】struct和typedef struct在C/C++中的区别