未处理的“System.ComponentModel.Win32Exception”类型的异常出现在 System.dll 中。其他信息: 拒绝访问。
程序伊甸园 2013-11-18 11:55:49 string dirResults = "";
ProcessStartInfo psi = new ProcessStartInfo();
Process proc = new Process();
if (proc.Id != 0)
{
psi.FileName = "nbtstat";
psi.RedirectStandardInput = false;
psi.RedirectStandardOutput = true;
//proc.StartInfo.UseShellExecute = false;
psi.Arguments = "-a " + IP;
psi.UseShellExecute = false;
proc = Process.Start(psi);
dirResults = proc.StandardOutput.ReadToEnd();
proc.WaitForExit();
}
//匹配mac地址
Match m = Regex.Match(dirResults, "\\w+\\-\\w+\\-\\w+\\-\\w+\\-\\w+\\-\\w\\w");
//若匹配成功则返回mac,否则返回找不到主机信息
if (m.ToString() != "")
{
return m.ToString();
}
else
{
return "找不到主机信息";
}
一到了这句就拒绝访问,本地一切OK 一道服务器就错误了。