c#中网卡的连接列表

本文关键字:连接 列表 网卡 中网 | 更新日期: 2023-09-27 18:18:02

我的系统中安装了两个网络接口卡,我想要连接到特定网卡的所有计算机的列表,或者我需要一个类似于DOS中的"arp -a"命令的代码。我需要一个c#代码来做到这一点。

c#中网卡的连接列表

如果您想要的是arp -a的输出,那么这很简单:

Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.FileName = "arp.exe";
p.StartInfo.Arguments = "-a";
p.Start();
string output = p.StandardOutput.ReadToEnd();
p.WaitForExit();
MessageBox.Show(output);  //etc... parse this for what you need

你当然需要加上:

using System.Diagnostics;