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;
}
}
|
|
|
|

0 comments:
Post a Comment