Kobe Kobe - 3 months ago 20
C++ Question

How can I change the current path using Boost.Filesystem

When starting the program I want to print the current path using current_path() ("C:\workspace\projects"). And then I want to be able to change the path to, lets say "c:\program files", so when i print again the current_path() I want to be printed "c:\program files". Something like this

int main()
{
cout << current_path() << endl; // c:\workspace\projects
aFunctionToChangePath("c:\program files");
cout << current_path() << endl; // c:\program files
}


Is there a function in the library that I am missing so I can acomplish this ?

Answer
int main()
{
   cout << current_path() << '\n'; // c:\workspace\projects
   current_path("c:\\program files");
   cout << current_path() << '\n';  // c:\program files
}
Comments