How can I get a path of a running process by name? For example, I know there is a process named "notepad" running, and I want to get the path of it. How to get the path without looping through all other processes?
Not this way!
using System.Diagnostics;
foreach (Process PPath in Process.GetProcesses())
{
if (PPath.ProcessName.ToString() == "notepad")
{
string fullpath = PPath.MainModule.FileName;
Console.WriteLine(fullpath);
}
}