DeleteFile() returning ERROR_FILE_NOT_FOUND

  • Thread starter Thread starter Andy Nugent
  • Start date Start date
A

Andy Nugent

As part of the clean up from my application I delete a series of temporary
files using DeleteFile(). However, some of the delete's work, and some
don't. The ones that don't return ERROR_FILE_NOT_FOUND.

I've used the handle utility from SysInternals to check if I have any
handles open to these files when I try and delete them and I don't.

I'm also outputting to the trace the full paths of the files, and I'm sure
that the path is correct (e.g. I cut and paste it into a delete command at
the DOS prompt and it works).

Also, if I put a break point on the call to DeleteFile() and then go into
explorer and delete the files manually everything works.

So... does anyone have any idea what is going wrong?

I'm fed up of looking at it and will probably just change the code to use
SHFileOperation() on Monday morning, but I'd be really interested in an
explanation of what's happening.

Thanks,

Andy.
 
Or use FILE_FLAG_DELETE_ON_CLOSE in your CreateFile call....

It'll only delete the file when ALL open handles are closed...

Dave
 
Back
Top