Created
December 21, 2016 17:11
-
-
Save alexander-williamson/d92e74b10e7550ad51ce43aee18d2a2c to your computer and use it in GitHub Desktop.
Find matching files PATH environment variable folders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private IEnumerable<string> GetExecutableFromPaths(string fileName) | |
{ | |
var path = Environment.GetEnvironmentVariable("PATH"); | |
var pathFolders = path.Split(';'); | |
foreach (var folder in pathFolders) | |
{ | |
var fullPath = Path.Combine(folder, fileName); | |
if (File.Exists(fullPath)) | |
yield return fullPath; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment