Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/263.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何检查进程是否仍在运行?_C#_.net_Winforms - Fatal编程技术网

C# 如何检查进程是否仍在运行?

C# 如何检查进程是否仍在运行?,c#,.net,winforms,C#,.net,Winforms,在构造函数中: if (Process.GetProcessesByName(@"C:\Program Files (x86)\Elgato\GameCapture\GameCapture.exe").Length == 0) { Process.Start(@"C:\Program Files (x86)\Elgato\GameCapture\GameCapture.exe"); } 问题是,即使正在运行的进程

在构造函数中:

if (Process.GetProcessesByName(@"C:\Program Files (x86)\Elgato\GameCapture\GameCapture.exe").Length == 0)
            {
                 Process.Start(@"C:\Program Files (x86)\Elgato\GameCapture\GameCapture.exe");
            }

问题是,即使正在运行的进程试图再次启动它。

进程的名称只是GameCapture。它是进程名而不是进程路径