I'm currently working on a project that works very closely with multiple executable files that I don't have any control over.. these executables all rely on its required files (some that my program creates and others by other executables that I dont have control over) being located within the same directory. These executables all create files and store them in the same directory as the executable was run from..
Currently for most of my testing I've been using a hard coded directory path which has been fine for me but obviously this won't work when the application is finished.. I'm just wondering on what the best way would be to handle the directory paths for these files.. I do have complete control on where to store the executables and files; just no control on how these executables handle their input/output.
The directory that contains a WinForms executable is:
You can use the
Application.ExecutablePath property which will give you your running executable's path. After this you can call the
System.IO.Path.GetDirectoryName() method and this will result the current directory of your executable.