1

Possible Duplicate:
How to get the application executable name in Windows (C++ Win32 or C++/CLI)?
Extracting the current executable name

I need to get the relative path of the executable file directory using C++. I have done the same program using C# which works perfectly.

System.IO.Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath)

I would like to get the similar result using C++.

Community
  • 1
  • 1
sasa
  • 11
  • 2

1 Answers1

0

Using boost::filesystem

#include <iostream>
#include <boost/filesystem.hpp>
using namespace std;
using namespace boost::filesystem;

int main(int argc, char * argv[])
{
    path p(argv[0]);

    cout << p.parent_path() << endl;

    return 0;
}
Sergei Nikulov
  • 5,029
  • 23
  • 36