Written on 2009年3月24日 @ 22:09 | by spirit | Tags: C#   | 浏览:

可用如下方法判断,如果超过5秒没有响应,则返回FALSE:



//判断网页是否存在
public static bool JugeWebURL(string URL) 
{ 
System.Net.WebResponse myRepTest; 
System.Net.WebRequest myTest=System.Net.WebRequest.Create(URL); 
myTest.Timeout=5000; 
bool link=true; 
try{myRepTest=myTest.GetResponse();} 
catch(Exception e){link=false;} 
return link; 
} 



若转载请注明出处: Spirit's Home
本文地址: http://www.7788sky.cn/post/Csharp_url_enable.html
  1. 1 Response to “C#判断网页URL地址是否有效”

  2. By lw8776 on 2011-10-24 17:26:56|

    谢谢分享~~~~~~~~~~

Post a Comment

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。