I have tried several ways to get MoveFileEx working with the DELAY_UNTIL_REBOOT flag without success. The FileRenameOperations key in the registry also shows that the method did not execute properly. What could be the cause?
I call my MoveFileEx function like this:
MoveFileEx(localFile, oldFile, MoveFileFlags.MOVEFILE_DELAY_UNTIL_REBOOT);
My WINAPI code is as follows:
[DllImport("kernel32.dll", EntryPoint = "MoveFileEx")]
internal static extern bool MoveFileEx(string lpExistingFileName, string lpNewFileName, MoveFileFlags dwFlags);
internal enum MoveFileFlags
{
MOVEFILE_REPLACE_EXISTING = 1,
MOVEFILE_COPY_ALLOWED = 2,
MOVEFILE_DELAY_UNTIL_REBOOT = 4,
MOVEFILE_WRITE_THROUGH = 8
}
This application is run under admin account. Could this be because I'm using 4 instead of 0x4 or is it some 64bit problem? Thanks!
EDIT: The Operation returns false and error code of 3.