title: C++: Use Boost Serialization to write/read files
body: <p>I need to write/read a file that contains a std::map. The file must be read at the program start up (if it exists). Im using boost's fstream, but im getting this:</p>
  
  <pre><code>"terminate called after throwing an instance of 'boost::archive::archive_exception'
    what():  input stream error"
  </code></pre>
  
  <p>Well, i really dont know what is happening.. these are my lines:</p>
  
  <pre><code>map&lt;int64_t, int64_t&gt; foo;
  filesystem::path myFile = GetWorkingDirectory() / "myfile.dat";
  [...............] // some code
  
  filesystem::ifstream ifs(myFile);
  archive::text_archive ta(ifs);
  if (filesystem::exists(myFile)
  {
     ta &gt;&gt; foo; // foo is empty until now, it's fed by myFile
     ifs.close();
  }
  </code></pre>
  
  <p>What im doing wrong? Any idea? 
  Thanks.</p>
  
  <p>P.S. Note that some lines after, i need to do the reverse action: write into myfile.dat the std::map foo.</p>
  
  <p>EDIT: all works if i use std::ifstream, saving the file in the same dir where im running the Application. But using boost and his path, something goes wrong.</p>