Boost.Filesystem how to find out in which directory your executable is?

You cannot, Boost.Filesystem does not provide such functionality.

But starting with Boost 1.61 you can use Boost.Dll and function boost::dll::program_location:

#include <boost/dll.hpp>
boost::dll::program_location().parent_path();

boost::filesystem::system_complete(argv[0]);

e.g.

[davka@bagvapp Debug]$ ./boostfstest 
/home/davka/workspaces/v1.1-POC/boostfstest/Debug/boostfstest

Note that this gives you the full path including the executable file name.


You can't do it reliably with boost::filesystem.

However if you're on windows you can call GetModuleFileName to get the complete path of the executable and then use boost::filesystem to get the directory. ( see parent_path)