Code:
#region CheckInternetConnection
public static bool CheckForInternetConnection()
{
try
{
using (var client = new WebClient())
{
using (var stream = client.OpenRead("http://google.com"))
{
return true;
}
}
}
catch
{
return false;
}
}