title: How to convert boost path type to string?
body: <p>Hello I currently have a program that gets a full path of a file's location and is put into a variable that is the type of: boost::filesystem2::path </p>
  
  <p>I have looked up how to do this and have found that using:</p>
  
  <pre><code>string result1 = boost::filesystem::basename (myPath)
  </code></pre>
  
  <p>will convert the path to string BUT it only converts the file name (e.g. if the path is "C:\name\bobsAwesomeWordDoc.docx" it just returns "bobsAwesomeWordDoc").</p>
  
  <p>I have found the following on how to convert the entire path to string,
  but I don't know how to implement it in my program. I have tried multiple ways but I am getting conversion errors.</p>
  
  <blockquote>
    <p>const std::string&amp; string( ): This routine returns a copy of the string with which the path was initialized, with formatting per the path grammar rules.</p>
  </blockquote>
  
  <p>(found <a href="http://www.ibm.com/developerworks/aix/library/au-boostfs/index.html" rel="noreferrer">here</a>)</p>
  
  <p>I have tried:</p>
  
  <pre><code>string result1 = string&amp; (myPath);
  </code></pre>
  
  <p>and a few other variations.</p>