querying netsh in c#

久未见 提交于 2019-12-06 12:27:00

问题


I've been trying to come up with an ideal way to query WiFi information using C#. I've tried the netsh method but was unsure how to separate the information. I notice that Vistumbler uses netsh. Is there a way that these developers would have separated the information when querying netsh or have they just performed a lot of string manipulation to cut out the irrelevant stuff.


回答1:


That is what I do usually. Call netsh, get the output and parse it.

Process p = new Process();
p.StartInfo.FileName = "netsh.exe";
p.StartInfo.Arguments = "netsh arguments...";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.Start();

string output = p.StandardOutput.ReadToEnd();
// parse output and look for results


来源:https://stackoverflow.com/questions/8274730/querying-netsh-in-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!