DeleteFile() returning ERROR_FILE_NOT_FOUND

G

Guest

Guest
Archived from groups: microsoft.public.windows.file_system,microsoft.public.win2000.file_system (More info?)

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.
 
G

Guest

Guest
Archived from groups: microsoft.public.windows.file_system,microsoft.public.win2000.file_system (More info?)

Or use FILE_FLAG_DELETE_ON_CLOSE in your CreateFile call....

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

Dave

> 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.
>