我正在使用以下代码启用&禁用nic但此代码有问题帮助我 [英] i m using following code to enable & disable nic but there is problem in this code help me
本文介绍了我正在使用以下代码启用&禁用nic但此代码有问题帮助我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SelectQuery query = new SelectQuery("Win32_NetworkAdapter", "NetConnectionStatus=2");
ManagementObjectSearcher search = new ManagementObjectSearcher(query);
foreach (ManagementObject result in search.Get())
{
NetworkAdapter adapter = new NetworkAdapter(result);//error in this line whats the problem
if (adapter.AdapterType.Equals("Ethernet 802.3"))
{
adapter.Disable();
}
}
我还添加了参考System.net;
[edit] rjm:添加了代码格式[/edit]
i have also added reference System.net;
[edit]rjm: added code formatting[/edit]
推荐答案
rahul_12789写道:
rahul_12789 wrote:
//此行中的错误是什么问题
//error in this line whats the problem
有什么错误吗?请理解,阅读您的问题的人无法猜测您的代码出了什么问题.
What''s the error? Please understand that people reading your question cannot guess what goes wrong in your code.
result.InvokeMethod("Disable",null);
试试这个
result.InvokeMethod("Disable", null);
try this
这篇关于我正在使用以下代码启用&禁用nic但此代码有问题帮助我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文