<p>When I get a reference to a <code>System.Diagnostics.Process</code>, how can I know if a process is currently running?</p>

This is a way to do it with the name:
```
```
Process[] pname = Process.GetProcessesByName("notepad");
if (pname.Length == 0)
  MessageBox.Show("nothing");
else
  MessageBox.Show("run");
```
```
You can loop all process to get the ID for later manipulation:
```
```
Process[] processlist = Process.GetProcesses();
foreach(Process theprocess in processlist){
   Console.WriteLine("Process: {0} ID: {1}", theprocess.ProcessName, theprocess.Id);
}
```
```