Why can't I change the 'last write time' of my newly created files?
<p>First off, I'm using Visual Studio 2015's implementation of the Filesystem library from the upcoming C++17 standard, which is based on Boost::Filesystem.</p>

<p>Basically, what I'm trying to do is save a file's timestamp (it's "last write time"), copy that file's contents into an archive along with said timestamp, then extract that file back out and use the saved timestamp to restore the correct "last write time".</p>

<pre><code>// Get the file's 'last write time' and convert it into a usable integer.
__int64 timestamp = chrono::time_point_cast&lt;chrono::seconds&gt;(fs::last_write_time(src)).time_since_epoch().count();

// ... (do a bunch of stuff in here)

//  Save the file
ofstream destfile(dest, ios::binary | ios::trunc);
destfile.write(ptr, size);

// Correct the file's 'last write time'
fs::last_write_time(dest, chrono::time_point&lt;chrono::system_clock&gt;(chrono::seconds(timestamp)));
</code></pre>

<p>The problem is that the new file will always end up with a timestamp equaling the time it was created (right now), as it I never called <code>last_write_time()</code> at all.</p>

<p>When I try copying the timestamp from one existing file to another, it works fine.  When I copy the timestamp from a file, then use <code>fs::copy</code> to create a new copy of that file, then immediately change the copy's timestamp, it also works fine.  The following code works correctly:</p>

<pre><code>// Get the file's 'last write time' and convert it into a usable integer.
__int64 timestamp = chrono::time_point_cast&lt;chrono::seconds&gt;(fs::last_write_time("test.txt")).time_since_epoch().count();
fs::copy("test.txt", "new.txt");
// Correct the file's 'last write time'
fs::last_write_time("new.txt", chrono::time_point&lt;chrono::system_clock&gt;(chrono::seconds(timestamp)));
</code></pre>

<p>I have no reason to suspect that storing the timestamp could be incorrect, but I have no other ideas. What might be causing this?</p>