Files
better-genshin-impact/Build/MicaSetup/Helper/Device/ConnectivityHelper.cs

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;
}
}