title: How to access the relative parent directory using <filesystem> in C++
body: <p>I'm wanting to know how to access the parent directory of the current working directory using the <code>&lt;filesystem&gt;</code> header for <code>C++ 17</code>. I then want to redirect to another folder from the parent directory to search for a file. </p>
  
  <p>Here's a conceptual example:</p>
  
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt;
  #include &lt;filesystem&gt;
  using namespace std;
  
  int main()
  {
      namespace fs = std::filesystem;
  
      fs::path working_dir(fs::current_path());
  
      fs::path parent_path(
          // ... Get path to parent dir of current working dir ... //
          );
  
      fs::current_path(parent_path);
      fs::current_path(
          // ... Redirect to subfolder called "sub_fold" ... //
          );
  
      // ... Search for specified file called "sub_file" to see if it exists ... //
      if (sub_file.exists())  // Psudo-code for returning if "sub_file" exists
      {
          // ... Do stuff with "sub_file" ... //
      }
      else cout &lt;&lt; "File does not exist in " &lt;&lt; fs::current_path &lt;&lt; endl;
  
      fs::current_path(working_dir);
  
      // ... Continue program ... //
      return 0;
  }
  
  </code></pre>