https://github.com/sgrottel/findexecutable
C# code to find the full path of an executable file by searching the system's search paths.
https://github.com/sgrottel/findexecutable
csharp csharp-library find-executables findexec
Last synced: 30 days ago
JSON representation
C# code to find the full path of an executable file by searching the system's search paths.
- Host: GitHub
- URL: https://github.com/sgrottel/findexecutable
- Owner: sgrottel
- License: mit
- Created: 2024-05-20T06:27:01.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2026-04-01T07:49:20.000Z (4 months ago)
- Last Synced: 2026-04-01T09:27:18.444Z (4 months ago)
- Topics: csharp, csharp-library, find-executables, findexec
- Language: C#
- Homepage:
- Size: 69.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FindExecutable
C# code to find the full path of an executable file by searching the system's search paths.
It is similar to `locate` or `get-command`.
The code is compatible with Windows, Linux, and MacOS.
[](https://www.nuget.org/packages/SGrottel.FindExecutable)
[](./LICENSE)
[](https://github.com/sgrottel/FindExecutable/actions/workflows/windows.yaml)
[](https://github.com/sgrottel/FindExecutable/actions/workflows/ubuntu.yaml)
[](https://github.com/sgrottel/FindExecutable/actions/workflows/macos.yaml)
Nuget:
[SGrottel.FindExecutable (https://www.nuget.org/packages/SGrottel.FindExecutable)](https://www.nuget.org/packages/SGrottel.FindExecutable)
The code was previously part of [SGrottel's Tiny Tools Collection (https://github.com/sgrottel/tiny-tools-collection)](https://github.com/sgrottel/tiny-tools-collection).
## Code
The code is located in the `FindExecutable` subdirectiory.
### Example
`FindExecutable` is a static class with one public static method:
```cs
public static string? FullPath(
string executable,
bool includeCurrentDirectory = false,
bool includeBaseDirectory = false,
IEnumerable? additionalPaths = null);
```
* `executable` -- The name of the executable to find.
* `includeCurrentDirectory` -- If set to true, the current execution directory is included in the list of search paths
* `includeBaseDirectory` -- If set to true, the application domain base directory is included in the list of search paths
* `additionalPaths` -- If set to something other then null, the paths iterated within are included in the list of search paths
The function will return the full file system path to the executable file requested, or null if the file is not found.
A description of how the function performs it's search can be found in the function comment in the source code.
### How to Add to Your Project
You can simple copy this directory and all it's files to your project.
Or, you can use the `SGrottel.FindExecutable.nuget` to import the files into your project.
This way, if you manage your dependencies with tooling, you can be automatically informed about updates.
[SGrottel.FindExecutable (https://www.nuget.org/packages/SGrottel.FindExecutable)](https://www.nuget.org/packages/SGrottel.FindExecutable)
## Contributions
Contributions to this project are welcome!
* Open [Issues](https://github.com/sgrottel/FindExecutable/issues) here on Github
* Create Pull Requests with Improvements (I recommend you talk to me first, e.g. via e-mail or issues)
* Reach out to me, e.g. via [the contact form on my website (https://www.sgrottel.de/about)](https://www.sgrottel.de/about).
## License
This project is freely available under the terms of the [MIT License](./LICENSE)
> Copyright (c) 2023-2026 Sebastian Grottel
>
> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in all
> copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
> SOFTWARE.