Reputation: 81
I'm using this kind of code to remove file after system reboot.
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
public static extern bool MoveFileEx(string lpExistingFileName,string pNewFileName, MoveFileFlags dwFlags);
Everything is ok with native iis-imitator in VS. But when I'm using IIS this piece of code fails without any error message.
I can suggest that this is a problem with permissions on IIS. But it's only my dumb suggestion.
Can you please help me with this case?
Upvotes: 0
Views: 283
Reputation: 612784
MoveFileEx()
. If it is false then the call failed.Marshal.GetLastWin32Error
to find out the Win32 error code. This sometimes helps narrow the problem down (although not always).In your comments you state that you are passing the MOVEFILE_DELAY_UNTIL_REBOOT
flag. The documentation for MoveFileEx
states:
This value can be used only if the process is in the context of a user who belongs to the administrators group or the LocalSystem account.
It seems likely that this is the root cause of the problem. Thanks to @Logan for pointing this out.
Upvotes: 1