 <p>You need to open the file before writing to it. Your <code>HANDLE hFind</code> is just a handle to iterate over directories/files, not an open handle to a file.</p> <p>Use <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858%28v=vs.85%29.aspx">CreateFile</a>() to open the file</p>