I'm writing a C# application that's being compiled and bundled with Mono's mkbundle
, and then run.
I'm attempting to access the folder that the executable is being run in, which works when I run the application from the directory that it's in, using ./example
. However, when running it relatively from another directory, such as ../Builds/example
, it returns the wrong directory, instead returning the place it was executed from.
This all works perfectly on Windows, however I also need it to work for Linux too.
The methods I've previously tried are:
AppDomain.Current.BaseDirectory
Path.GetDirectoryName(Assembly.ExecutingAssembly().Location)
(also triedEntryAssembly
)
All of these return the incorrect directory, rather than the actual location of the executable.