c# - 如何获取网卡名称

标签 c# windows-server-2008-r2 ethernet nic

谁知道如何获取网卡名

当我执行 ipconfig/all 时 我可以得到这个

Ethernet adapter XC99HT:

   Connection-specific DNS Suffix  . : xx.xx.com
   Description . . . . . . . . . . . : HP NC382i DP Multifunction Gigabit Server
 Adapter
   Physical Address. . . . . . . . . : F4-CE-46-94-E8-B0
   DHCP Enabled. . . . . . . . . . . : No
   Autoconfiguration Enabled . . . . : Yes
   IPv4 Address. . . . . . . . . . . : 177.77.153.48(Preferred)
   Subnet Mask . . . . . . . . . . . : 255.255.255.0
   Default Gateway . . . . . . . . . : 177.77.153.1
   DNS Servers . . . . . . . . . . . : 177.77.124.129
                                       177.77.124.130
   Primary WINS Server . . . . . . . : 177.77.124.129
   Secondary WINS Server . . . . . . : 177.77.124.130
   NetBIOS over Tcpip. . . . . . . . : Enabled

想入手《HP NC382i DP多功能千兆服务器》 适配器”,只需使用/传递以太网名称“XC99HT”

最佳答案

类似于 this

public static void ShowInterfaceSummary()

{

NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in interfaces)
{                
    Console.WriteLine ("Name: {0}", adapter.Name);
    Console.WriteLine(adapter.Description);
    Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length,'='));
    Console.WriteLine("  Interface type .......................... : {0}", adapter.NetworkInterfaceType);
    Console.WriteLine("  Operational status ...................... : {0}", 
        adapter.OperationalStatus);
    string versions ="";

    // Create a display string for the supported IP versions.
    if (adapter.Supports(NetworkInterfaceComponent.IPv4))
    {
         versions = "IPv4";
     }
    if (adapter.Supports(NetworkInterfaceComponent.IPv6))
    {
        if (versions.Length > 0)
        {
            versions += " ";
         }
        versions += "IPv6";
    }
    Console.WriteLine("  IP version .............................. : {0}", versions);
    Console.WriteLine();
}
Console.WriteLine();

关于c# - 如何获取网卡名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11090780/

相关文章:

c# - 将文件上传到 asp.net 中的 ftp 文件夹

php - php 会在每次请求后自动关闭 TCP 连接吗?

python - 在 linux 中获得有关 "Ethernet cable plugged in"事件的通知

delphi - 如何使用Delphi获取网卡的MAC地址?

C# WebRequest (400) 第二次调用错误请求

c# - 如何使用 MVC 4 上传大文件?

c# - 具有完全权限控制的 Windows 2008 R2 加载 DLL 失败

powershell - Get-WindowsFeature 的替代方案

android - 在android中将静态ip设置为以太网

c# - 为什么我需要覆盖 C# 中的 .Equals 和 GetHashCode