Tuesday, February 3, 2009

How to check whether Internet connection is avaialable or not

using System.Net;

WebRequest objWebReq;
WebResponse objResp;
public Boolean IsConnectionAvailable()
{
System.Uri objUrl = new System.Uri("http://www.google.com/");

objWebReq = WebRequest.Create(objUrl);

try
{
objResp = objWebReq.GetResponse();
objResp.Close();
objWebReq = null;
return true;
}
catch (Exception ex)
{
objResp.Close();
objWebReq = null;
return false;
}
}


No comments:

Creative Commons License
Disclaimers:We have tried hard to provide accurate information, as a user, you agree that you bear sole responsibility for your own decisions to use any programs, documents, source code, tips, articles or any other information provided on this Blog.