[In addition to correct answer by Marcus Kramer:]
Listing processes by the process name is not a reliable thing. Two totally unrelated processes can accidentally have the same name. Besides, hard-coding any name means poorly maintainable code. I don't know your purpose, but I can assume you are killing all the processes of the same application. In this case, you can check up if the application is the same by comparing the value of
Process.MainModule.FileName
:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.mainmodule.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.processmodule.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.processmodule.filename.aspx[
^].
Of course, in this case, you won't be able to detect the copy of the same application executed under some different name or just located in different directory, but, in this case, only a bitwise comparison of image files can help, you probably won't need to consider such cases.
—SA