I am writing a C++ program in which I change the working directory with
working_directory is a string. Is there a good way to, later in the program, reset the working directory to its original value? I understand that one solution would be to use a variable
string initial_directory = std::filesystem::current_path() before I change the working directory and then later reset it with
std::filesystem::current_path(initial_directory), but I feel like there should be a more elegant solution.
Source: Windows Questions C++