If you're really going to be delivering this program to users I would recommend including the exe
in the build output and referencing it with a relative path. This will ensure the program always works. If it's more like an internal tool or something that doesn't require such a nice user experience then just put the path in the App.Config
or some other ini/config file. Read the path from there and use it where you have the hard coded path.
Hard-coding a path in a dll, or How to write a wrapper
-
09-07-2023 - |
Question
I made a wrapper to gnuplot in C#. Currently it's just a cs file that's a class. The class pipes commands to/from gnuplot.exe. Currently, you'd have to go into the code, set the path to wherever your gnuplot is, then recompile.
class GnuPlot
{
public static string PathToGnuplot = @"C:\Program Files (x86)\gnuplot\bin";
What's the proper way to structure a wrapper that depends on an .exe in people's system? Do people want a config file? a whole install msi just to confirm where the path to gnuplot is?
When people make a 3rd party gui for a command line program, how do they handle distribution of the program and linking up with the presumably already installed command line program?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow