Not everything is clear in your explanation, but I'll start to answer.
The *.exe files is not all the "executable files", but if this is all you need, you can obtain the whole set of the file using the method
System.IO.Directory.GetFile
, the 3rd method of these three, the one with
SearchOption
:
https://msdn.microsoft.com/en-us/library/system.io.directory.getfiles%28v=vs.110%29.aspx[
^],
https://msdn.microsoft.com/en-us/library/ms143316(v=vs.110).aspx[
^],
https://msdn.microsoft.com/en-us/library/ms143448%28v=vs.110%29.aspx[
^].
SearchOption.AllDirectories
gives you the all the list of files at once, taken by recursing the directories.
Now, "all the file installed" is completely different thing and "all running on your machine" is another different thing. If you meant that all of the above is irrelevant to both of these problem, you were perfectly right.
Let's start with "all running". No, this is not a correctly posed problem. Files are not running. Running are applications and processes. You can get all processes in the system:
https://msdn.microsoft.com/en-us/library/1f3ys1f9(v=vs.110).aspx[
^].
Then you can take each instance of the returned processes, of the type
System.Diagnostics.Process
, and get all the information of each process:
https://msdn.microsoft.com/en-us/library/system.diagnostics.process%28v=vs.110%29.aspx[
^].
Now, we are coming to files. No, it's not just the file. You have to understand that each process used one or more executable files, and executable file is not *.exe. It could be *.dll, and a lot more. Real "executable file" is the PE file. You need to understand what it really is:
https://en.wikipedia.org/wiki/Portable_Executable[
^].
To get all the information, you need to get the properties of each process,
Process.Modules
and
Process.MainModule
:
https://msdn.microsoft.com/en-us/library/system.diagnostics.process.mainmodule(v=vs.110).aspx[
^],
https://msdn.microsoft.com/en-us/library/system.diagnostics.process.modules(v=vs.110).aspx[
^].
Then, from module, you can come to executable files:
https://msdn.microsoft.com/en-us/library/system.diagnostics.processmodule%28v=vs.110%29.aspx[
^],
https://msdn.microsoft.com/en-us/library/system.diagnostics.processmodule.filename(v=vs.110).aspx[
^],
(and see other properties).
I want to stop here for now. It's more than enough for a single answer. Please tell me if you still want to know about "installed applications" (again, not files, but not processes; applications). I want to warn you: this topic is much harder, and at the same time, much less important, less fundamental and more platform-specific. I'm not sure you really need to list it. But if you think you need, let me discuss it in a separate answer. This one is already a bit too much.
—SA