DeleteFile, then MoveFile Fails. is Delete Asynchronous?

I am currently having problems DeleteFile (or what i believe to be DeleteFile).
If I delete a file, check if the file is deleted with DoesFileExist (it is) then use MoveFile to a file with the same name/location as the that was just deleted, I receive a Error 183, can't move file because a file with that name already exists.

I am doing this in Vista Beta 2, and the test was conducted in the C:\ProgramData folder.

If the same test was conducted in a directory in Program Files, the files were virtualized and the same error was not seen.

Also if a sleep for 1 millisecond was entered directly before the MoveFile no errors were seen.

Is this a known issue or has the DeleteFile been changed?

[755 byte] By [lbland] at [2008-2-24]
# 1

if someone else has the file open with FILE_SHARE_DELETE then DeleteFile() will succeed but the file won't go away until the last open handle on that file is closed.

Chris

Chris_Guzak at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Search, Organize and Visualize in Windows Vista...
# 2
No one has the file open. I still see the error.
This can be recreated using a simple unit tester.

Create two file (make sure to close them as well). Delete one of the files and immediately move the other file to the delete file name.

lbland at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Search, Organize and Visualize in Windows Vista...
# 3

can you post the code for this?

what file type is this that you are updating?

Note that Win32 offers the ReplaceFile() API that is typically used to implement "safe save" (atomic update of a file). perhaps you should look into that to see if it has the same behavior or works in this case?

Chris_Guzak at 2007-8-30 > top of Msdn Tech,Software Development for Windows Vista,Search, Organize and Visualize in Windows Vista...

Software Development for Windows Vista

Site Classified