【发布时间】:2021-03-20 00:17:10
【问题描述】:
当我从命令行使用“路由打印”时,我会得到所有数据路由表。我需要在 c# 中获取相同的数据
我试过的是
foreach (NetworkInterface ni in NetworkInterface.GetAllNetworkInterfaces())
{
if (ni.NetworkInterfaceType == NetworkInterfaceType.Wireless80211 || ni.NetworkInterfaceType == NetworkInterfaceType.Ethernet)
{
foreach (UnicastIPAddressInformation ip in ni.GetIPProperties().UnicastAddresses)
{
if (ip.Address.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
{
//some code here
}
}
}
}
实际上,这个代码块提供了一些数据,但我需要上图中的所有地图。我需要网络掩码、网关、接口、指标等。感谢您抽出宝贵时间。
【问题讨论】:
标签: c# .net winforms networking ip