Page 1 of 1
How to check the Internet connection status?
Posted: Mon Feb 11, 2013 1:33 pm
by AutomationTester
Hai,
Can you tell me, how to check the internet connection status(Active or inactive) through code?
Code should be in C#.
Thanks and Regards
Amir aka AutomationTester
Re: How to check the Internet connection status?
Posted: Mon Feb 11, 2013 1:49 pm
by Support Team
Hi,
AutomationTester wrote:Can you tell me, how to check the internet connection status(Active or inactive) through code?
Code should be in C#.
Use following code
public static bool HasConnection()
{
try
{
System.Net.IPHostEntry i = System.Net.Dns.GetHostEntry("www.google.com");
return true;
}
catch
{
return false;
}
}
FYI, it just took about 30 seconds to find this part of code using Google.
Regards,
Peter
Ranorex Team
Re: How to check the Internet connection status?
Posted: Tue Feb 12, 2013 7:45 am
by AutomationTester
Hai Peter,
Works like a Charm. Thanks
Thanks
Amir aka AutomationTester