Last active
January 6, 2020 14:03
-
-
Save SamKr/5d6082cec887b5d88a3b008cb9170150 to your computer and use it in GitHub Desktop.
Checks for an active internet connection
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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