Click to See Complete Forum and Search --> : DeleteFile() Function


patrick22
March 23rd, 2008, 11:01 PM
Hi,

when i try to delete a file with DeleteFile function it returns 0 and the error code is 32 ( ERROR_SHARING_VIOLATION ).

Can you tell me how i can force the Deletion of the file?I know that we can mark it for deletion on restart( MoveFileEx function ), but is it there another way to do it?

Can we get a list of the file's opened handles, and then close them all and finally delete the file? If yes, what is the function to get the file's opened handles?


Thanks in advance.

richard_tominez
March 24th, 2008, 09:39 AM
Check the file that you want to delete if it is using by another program. Then, use the DeleteFile() function.

patrick22
March 24th, 2008, 10:18 AM
The file is used by other process.

Marc G
March 24th, 2008, 01:38 PM
If it's locked by another process, it's a very bad idea to forcefully delete the file. The application has locked it for a reason. Use MoveFileEx to do it on the next reboot like you already mentioned.