title: std::filesystem error: directory iterator cannot open directory: Not a directory
body: <p>I'm working on a project for school and having a problem using C++ std::filesystem while trying to iterate through a directory's files. I create a path object from a string passed into the command line (argv2 is &quot;C:\cygwin64\home\landl\CS2341\cs2341_project_data.zip\cs2341_data&quot;), then try to simply print out the filename of all the files in filepath:</p>
  <pre><code>        fs::path filepath = argv2;
          for (const auto&amp; dirEntry: fs::directory_iterator(filepath)) {
              std::cout &lt;&lt; dirEntry.path() &lt;&lt; std::endl;
          }
  </code></pre>
  <p>But I get the following error when running the code:</p>
  <pre><code>terminate called after throwing an instance of 'std::filesystem::filesystem_error'
    what():  filesystem error: directory iterator cannot open directory: Not a directory [C:\cygwin64\home\landl\CS2341\cs2341_project_data.zip\cs2341_data]
  </code></pre>
  <p>I think I understand what the error is saying, that the given string is not a filepath that can be opened. I don't understand why though, because it's the full file path of a folder that contains the files I want to iterate over. Why does passing this string in not work? I saw similar examples that ran passing in a string in a similar way.</p>
  <p>I couldn't find anything either that explained why this is happening, either in the std::filesystem documentation or on this website.
  I'm totally new to using std::filesystem so I would appreciate any input. Thank you!</p>