Atomic file update in Windows
<p>I have a program that periodically updates a file that is then updated on other machines via Dropbox.</p>

<p>So far I've been creating a temporary file, writing to it, and then calling <code>ReplaceFile</code>. However, Dropbox sees it as a separate delete+create operation, and as a result, the file will be deleted on other machines before being created again (possibly after some delay), which is not acceptable.</p>

<p>In fact, <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/hh802690(v=vs.85).aspx#applications_updating_a_single_file_with_document-like_data" rel="nofollow">Microsoft recommends ReplaceFile as an alternative to Transactional NTFS</a>, when it is clearly not doing the job.</p>

<p>Is there any way to atomically update the file contents in this scenario?</p>