Last active
June 17, 2023 00:17
-
-
Save Cdddo/68ea6a45e7319d9f9a995335fd493485 to your computer and use it in GitHub Desktop.
Internet Check
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
using System.Net.NetworkInformation; | |
public static bool CheckForInternetConnection() | |
{ | |
try | |
{ | |
using (var ping = new Ping()) | |
{ | |
var result = ping.Send("8.8.8.8", 2000); | |
return result.Status == IPStatus.Success; | |
} | |
} | |
catch | |
{ | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment