title: C++ File System
body: <p>I am trying to add these functions.</p>
  
  <pre><code>std::string GetDirectory(std::string path_name) {
      boost::filesystem::path path(path_name.c_str());
  
      path_name = path.string();
  
      path_name.erase(
          path_name.substr(
              path_name.find_last_of(DIRECTORY_SEPARATOR),
              path_name.length()
          )
      );
      return path_name;
  }
  
  std::string GetName(std::string path_name) {
      boost::filesystem::path path(path_name.c_str());
  
      path_name = path.string();
  
      path_name.erase(
          path_name.substr(
              0, 
              path_name.find_last_of(DIRECTORY_SEPARATOR)
          )
      );
  
      path_name.erase(
          path_name.substr(
              path_name.find_last_of("."), 
              path_name.length()
          )
      );
      return path_name;
  }
  
  std::string GetExtension(std::string path_name) {
      boost::filesystem::path path(path_name.c_str());
  
      path_name = path.string();
  
      path_name.erase(
          path_name.substr(
              0, 
              path_name.find_last_of('.')
          )
      );
      return path_name;
  }
  </code></pre>
  
  <p>I am trying to add:</p>
  
  <blockquote>
    <p>C:\Windows\Users\Example\Desktop\test.txt</p>
  </blockquote>
  
  <p>GetDirectory   </p>
  
  <blockquote>
    <p>C:\Windows\Users\Example\Desktop</p>
  </blockquote>
  
  <p>GetName</p>
  
  <blockquote>
    <p>test</p>
  </blockquote>
  
  <p>GetExtension</p>
  
  <blockquote>
    <p>txt</p>
  </blockquote>
  
  <p>I get errors though between path_name and erase (the period).
  Help would be much appreciated, Thank you. </p>
  
  <p>Please requested error messages:</p>
  
  <blockquote>
    <p>1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppBuild.targets(368,5): warning MSB8004: Output Directory does not end with a trailing slash.  This build instance will add the slash as it is required to allow proper evaluation of the Output Directory.
    1>  main.cpp
    1>main.cpp(287): error C2664: 'std::_String_iterator>> std::basic_string,std::allocator>::erase(std::_String_const_iterator>>,std::_String_const_iterator>>)': cannot convert argument 1 from 'std::basic_string,std::allocator>' to 'unsigned int'
    1>  main.cpp(287): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    1> main.cpp(301): error C2664: 'std::_String_iterator>> std::basic_string,std::allocator>::erase(std::_String_const_iterator>>,std::_String_const_iterator>>)': cannot convert argument 1 from 'std::basic_string,std::allocator>' to 'unsigned int'
    1>  main.cpp(301): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    1> main.cpp(307): error C2664: 'std::_String_iterator>> std::basic_string,std::allocator>::erase(std::_String_const_iterator>>,std::_String_const_iterator>>)': cannot convert argument 1 from 'std::basic_string,std::allocator>' to 'unsigned int'
    1>  main.cpp(307): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
    1> main.cpp(321): error C2664: 'std::_String_iterator>> std::basic_string,std::allocator>::erase(std::_String_const_iterator>>,std::_String_const_iterator>>)': cannot convert argument 1 from 'std::basic_string,std::allocator>' to 'unsigned int'
    1>  main.cpp(321): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called</p>
  </blockquote>