I want to find whether a certain DLL is available on the system path. in Powershell, I can use get-command myfile.dll
, and in cmd I can use where myfile.dll
.
How can I do that in C#? Do I have to manually parse Environment.GetEnvironmentVariable("path")
, or is there a better way?
Not sure about where
, but Get-Command
internally resolves the file location using the following algorithm (overly simplified):
Environment.GetEnvironmentVariable("PATH")
PATH
entry with Directory.EnumerateFiles()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.