25 lines
537 B
C#
25 lines
537 B
C#
using System.Net;
|
|
using System.Net.Sockets;
|
|
|
|
namespace TrackCenter.Application.Helpers;
|
|
|
|
public class NetUtil
|
|
{
|
|
/// <summary>
|
|
/// 得到局域网IP地址
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static string GetLanIp()
|
|
{
|
|
foreach (var hostAddress in Dns.GetHostAddresses(Dns.GetHostName()))
|
|
{
|
|
if (hostAddress.AddressFamily == AddressFamily.InterNetwork)
|
|
{
|
|
return hostAddress.ToString();
|
|
}
|
|
}
|
|
|
|
return string.Empty;
|
|
}
|
|
}
|