Which site is a port connected to ?

  • Thread starter Thread starter Craig Lister
  • Start date Start date
That's the dirty way of doing it, but I guess I can pipe the output to a
file, and then do some work on the file to achieve the desired outcome. But
... how do I execute a dos command from c#? (Basic question.. I know...)
 
using System.Diagnostics;

....

Process p = new Process();

p.StartInfo.FileName = "netstat";
p.StartInfo.Arguments = "-a";
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.UseShellExecute = false;
p.Start();

string output = p.StandardOutput.ReadToEnd();

// do something with output.
 
Craig Lister said:
Is it possible to hide the DOS PROMPT window that pops up ?

Try
p.StartInvo.CreateNoWindow = false;

Can't recall if that works for the console or not, but its worth a shot.
 
Back
Top