C
C#9mo ago
swagrid

✅ Get full paths to executables in %PATH%

Is there an easy way to get the full path of a program that's available in the shell because of the PATH environment variable (like gcm does in powershell or which on unix)? e.g. ResolvePath("dotnet") would return C:\Program Files\dotnet\dotnet.exe I don't want to start a process and I don't want to iterate over PATH myself.
2 Replies
sibber
sibber9mo ago
iterate over PATH yourself something like
Environment.GetEnvironmentVariable("PATH").First(x => "dotnet.exe".Equals(Path.GetFileName(x.AsSpan()), StringComparison.OrdinalIgnoreCase))
Environment.GetEnvironmentVariable("PATH").First(x => "dotnet.exe".Equals(Path.GetFileName(x.AsSpan()), StringComparison.OrdinalIgnoreCase))
Accord
Accord9mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.