The method using ping checks whether there is an internet connection or not?
In C#.NET
The following namespace is required:
using System.Net.NetworkInformation;
/// <Summary>
/// Checks whether an Internet connection is available.
/// </Summary>
/// <Returns>
/// True / false
/// </Returns>
/// Site: WiseCodes.Com
public static bool wcCheckInternetConnectionStatus()
{
Ping pingSender = new Ping();
try
{
PingReply pReply = pingSender.Send("www.microsoft.com", 100);
return pReply.Status == IPStatus.Success;
}
catch
{
return false;
}
}
Link: System.Net.NetworkInformation Namespace (Via MSDN)
Happy Programming!!
Tags: .NET, C#.Net, OpenSource