C# + .NET : Find the path of an app like chrome.exe in the computer (all disks, all directories)

the best that i have found about my problem is :

var filePaths = Directory.EnumerateFiles(@"C:\", "chrome.exe", new EnumerationOptions
{
    IgnoreInaccessible = true,
    RecurseSubdirectories = true
});
Console.WriteLine(filePaths);

But i dont know how to output to a string the appPath, it output this :

System.IO.Enumeration.FileSystemEnumerable`1[System.String]

How can it output this : C:\Program Files\Google\Chrome\Application
And for any application instead of chrome...


Solution 1:

filePaths is a collection of multiple strings, so you'll need to iterate through it.

foreach (string path in filePaths)
{
  Console.WriteLine(path);
} 

You can also consider functions like String.Join().