I am trying to call MoveFile to move a file to a new directory. Then make a new file with same name in the location it was moved from. I want the creation time attribute of the new file to be set to whatever the time is at the time the new file is created. I expected this would be the normal behavior when using MoveFile. But for some reason it keeps setting the creation time to the creation time of the old file.
FILE* m_pFile;
::MoveFile(bstrRequestedFile, bstrTimestampLogFile);
m_pFile = ::_wfsopen(bstrRequestedFile, L"wt", _SH_DENYNO);
When I step through the code slowly or add a sleep between the Move and open lines the creation time will be current when the file is opened. I'd like to avoid the sleep if possible. Also I have tried things like SetFileTime but was not working for me. The file is getting moved successfully and does not show in the original location until the open line.