我如何使用Boost.Filesystem更改当前路径

| 启动程序时,我想使用current_path()(\“ C:\\ workspace \\ projects \”)打印当前路径。然后,我希望能够将路径更改为\“ c:\\ program files \”,所以当我再次打印current_path()时,我想将其打印为“ c:\\ program files \” 。像这样
int main()
{
   cout << current_path() << endl;  // c:\\workspace\\projects
   aFunctionToChangePath(\"c:\\program files\");
   cout << current_path() << endl;  // c:\\program files
}
库中是否缺少我可以完成的功能?     
已邀请:
int main()
{
   cout << current_path() << \'\\n\'; // c:\\workspace\\projects
   current_path(\"c:\\\\program files\");
   cout << current_path() << \'\\n\';  // c:\\program files
}
    
如果要更改到其他目录,则建议尝试此操作 例:
boost::filesystem::path full_path( boost::filesystem::current_path() );
std::cout << \"Current path is : \" << full_path << std::endl;
//system(\"cd ../\"); // change to previous dir -- this is NOT working
chdir(\"../\"); // change to previous dir -- this IS working
boost::filesystem::path new_full_path( boost::filesystem::current_path() );
std::cout << \"Current path is : \" << new_full_path << std::endl;
    

要回复问题请先登录注册