RE: Vista Undeletable File Problem
- From: lelteto <lelteto@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 21 Jan 2007 12:57:01 -0800
Please understand that FileDelete retursn TRUE (ie. it acknowledges that the
file deleted) - and it WILL be deleted as soon as all handles are closed. The
system cannot delete a file while it has open handles - but it allows you to
INITIATE the delete operation.
My "constructive" advice was to check that you did release the DLL
(FreeLibrary). If you do that then it's the system (Vista) which still keeps
a handle to the file.
My other "constructive" advice was that if you create with delete-on-close
than you don't even have to worry about this issue.
Laszlo Elteto
SafeNet, Inc.
"cyril macdonald" wrote:
Please don't post unless you have constructive comments..
This issue occurs only on Vista, and if I delete a file, and FileDelete
returns true, then it should be deleted.
"lelteto" wrote:
Windows just tries to "keep around" the DLL ebcause you used it recently in
the app. Did you unload the DLL? Even if yes, Windows waits a while in the
assumption that you may want to use it again.
The reason you see this behavior has nothing to do with Vista. It's the
behavior with OPEN files. Windows allows you delete an open file - but the
delete operation will actually be done only when all handles to the file is
closed. Since Windows keeps the DLL open (as I said, assuming you may want to
use it again - it's just optimization to avoid unnecessary expensive opens)
it is not deleted until you close the application - at which point Windows
also closes the handle to it and the file is really deleted.
I wouldn't worry about this. The best way to handle these kind of files is
to create it with "delete-on-close" flag, then you don't even have to call
the delete function. (An added benefit is that even if your application
crashes the file still will be deleted.)
Laszlo Elteto
SafeNet, Inc.
"cyril macdonald" wrote:
I have a high integrity process which creates a DLL in the Program Files
folder. I delete the DLL when I am done with it, and the DeleteFile function
returns true.
However, If I then iterate through the files with FindFirstFile/FindNextFile
within my app, I see the file is still there. If I try to delete it again
(using DeleteFile), I get "access denied" error code.
If I go in explorer and try to delete the file, it deletes successfully,
however if I refresh explorer, the file returns immediately.
If I check the security attributes of the file in explorer, this operation
is denied even after I escalate privileges through the UAC dialog. I can't
take ownership of the file either (even as admin).
When my application terminates, the DLL is automatically deleted.
Does anyone know what might be causing this behaviour? Is this
virtualisation run amok? I tried disabling virtualisation in my process
token, but this appears to have had no effect.
- References:
- RE: Vista Undeletable File Problem
- From: cyril macdonald
- RE: Vista Undeletable File Problem
- Prev by Date: RE: Certs on smart card, re-prompting for PIN (Internet Explorer 6)
- Next by Date: Re: Certs on smart card, re-prompting for PIN (Internet Explorer 6)
- Previous by thread: RE: Vista Undeletable File Problem
- Next by thread: Certs on smart card, re-prompting for PIN (Internet Explorer 6)
- Index(es):
Relevant Pages
|