Created
April 14, 2014 09:28
-
-
Save alxsimo/10631807 to your computer and use it in GitHub Desktop.
[C#] CheckForInternetConnection - comprobar conexión a internet
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
public static bool CheckForInternetConnection() | |
{ | |
try | |
{ | |
using (var client = new WebClient()) | |
using (var stream = client.OpenRead("http://www.google.com")) | |
{ | |
return true; | |
} | |
} | |
catch | |
{ | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment