mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-03-31 10:29:52 +08:00
23 lines
537 B
C#
23 lines
537 B
C#
using System.Net.NetworkInformation;
|
|
|
|
namespace MicaSetup.Helper;
|
|
|
|
public static class ConnectivityHelper
|
|
{
|
|
public static bool IsNetworkAvailable => NetworkInterface.GetIsNetworkAvailable();
|
|
|
|
public static bool Ping(string hostNameOrAddress = null!)
|
|
{
|
|
try
|
|
{
|
|
using Ping ping = new();
|
|
PingReply reply = ping.Send(hostNameOrAddress ?? "www.microsoft.com");
|
|
return reply?.Status == IPStatus.Success;
|
|
}
|
|
catch
|
|
{
|
|
}
|
|
return false;
|
|
}
|
|
}
|