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

Rella picture Rella · Apr 17, 2011 · Viewed 24.5k times · Source

So I run my app. I need for it to know where its executable is. How to find path to it using Boost.Filesystem?

Answer

davka picture davka · Apr 17, 2011
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.