Skip to content

Instantly share code, notes, and snippets.

@SamKr
Last active January 6, 2020 14:03
Show Gist options
  • Save SamKr/5d6082cec887b5d88a3b008cb9170150 to your computer and use it in GitHub Desktop.
Save SamKr/5d6082cec887b5d88a3b008cb9170150 to your computer and use it in GitHub Desktop.
Checks for an active internet connection
internal static bool CheckForInternetConnection()
{
try
{
using (var client = new WebClient())
using (client.OpenRead("http://google.com/generate_204"))
{
return true;
}
}
catch
{
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment