访问服务器时提示System.ComponentModel.Win32Exception: 拒绝访问
System.Net.IPAddress[] addressList = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName()).AddressList;
string ip = addressList[0].ToString();
public string GetMac(string clientIp)
{
string mac = "";
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "nbtstat";
process.StartInfo.Arguments = "-a " + clientIp;
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
string output = process.StandardOutput.ReadToEnd();
int length = output.IndexOf("MAC Address =");
if (length > 0)
{
mac = output.Substring(length + 14, 17);
}
return mac;
}
process.Start();System.ComponentModel.Win32Exception: 拒绝访问,但是我在本地测试没问题,为什么代码传到服务器上就报错