title: get directory from file path c++
body: <p>What is the simplest way to get the directory that a file is in? I'm using this to find the working directory.</p>
  
  <pre><code>string filename = "C:\MyDirectory\MyFile.bat" 
  </code></pre>
  
  <p>In this example, I should get "C:\MyDirectory".</p>