Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the current path using Boost.Filesystem

Tags:

c++

boost

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 ?

like image 446
Adrian Avatar asked Apr 15 '11 13:04

Adrian


Video Answer


1 Answers

int main()
{
   cout << current_path() << '\n'; // c:\workspace\projects
   current_path("c:\\program files");
   cout << current_path() << '\n';  // c:\program files
}
like image 187
Yakov Galka Avatar answered Oct 05 '22 13:10

Yakov Galka