EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Cannot delete file

Also by EldoS: CallbackProcess
A component to control process creation and termination in Windows and .NET applications.
#7034
Posted: 07/23/2008 13:46:25
by Dan Cooper (Basic support level)
Joined: 06/27/2007
Posts: 125

We are seeing occasions where a folder cannot be deleted because it is in use, we do not open any handles to folders other than enumeration handles which are closed when the the CloseEnumeration callback is called. Is it possible that a handle is still open to the folder? If so, how can we force these handles to be freed to allow the folder to be deleted?
#7036
Posted: 07/23/2008 14:09:37
by Eugene Mayevski (EldoS Corp.)

If the enumeration of the folder is active, it takes a handle. And of course, this open handle prevents the folder from being deleted. Is this the case or I have misunderstood the question?


Sincerely yours
Eugene Mayevski
#7294
Posted: 08/15/2008 05:14:39
by Dan Cooper (Basic support level)
Joined: 06/27/2007
Posts: 125

After further investigation it seems that we do not get a close event for certain executable files which means our file handle is still open and prevents the containing folder being deleted or renamed. This only seems to have started happening in the latest version of CBFS (.NET 1.1). It also only seems to be executable files which fail to be closed. Could this be a bug in the new CBFS?
#7295
Posted: 08/15/2008 05:48:38
by Eugene Mayevski (EldoS Corp.)

1) What exactly build is "the latest" and which one was used before? In other words, are you comparing different builds of CBFS 2.0 or you are comparing CBFS 2.0 with CBFS 1.x?
2) The files are not always closed immediately. This has been discussed a number of times in the forum. Here's some information from the Getting Started article:

Quote

After the file is read or written, it is closed by the OS. Closing doesn't necessarily happens as soon as the application, that used the file, calls CloseFile() Win32 function. In some cases the OS (it's cache manager) keeps the handle to the file open for some time.

Callback File System receives the request to close the file and calls OnCloseFile callback. Much like the OS, Callback File System driver delays closing of the files in order to save resources and time. This behaviour can be disabled by calling AllowDelayedClose() method and passing False as parameter.


Sincerely yours
Eugene Mayevski
#7298
Posted: 08/15/2008 06:03:48
by Volodymyr Zinin (EldoS Corp.)

Please
Quote
Dan Cooper wrote:
It also only seems to be executable files which fail to be closed.

Do the processes associated with the executables exist or not? You can check it using the system Task Manager console or Process Explorer from sysinternals. If such processes still exist then try to kill them and check whether the OnClose callback is called after.

Also by means of Process Explorer from sysinternals you can find what process opened a file (from its menu "Find"). Try to find whether files from the undeletable directory still opened.
#7299
Posted: 08/15/2008 06:15:57
by Dan Cooper (Basic support level)
Joined: 06/27/2007
Posts: 125

We have been doing some more research on this problem and it seems that the OnClose event does not get called. We think this is the case as we now log every Open/Create and every Close call, we end up with one file left without an OnClose call. The process which owns the handle is "explorer.exe" and on using Process Explorer we can see that the process is not running and Explorer does not have a handle open to this file.

When we open the folder again,we can can see that a second OnOpen event is called for the open file while Explorer retrieves the icons for the executables and then a subsequent OnClose event which still leaves the first handle open.
#7304
Posted: 08/15/2008 07:27:16
by Volodymyr Zinin (EldoS Corp.)

Check that there are no opened files in a directory that is being deleted. Use Process Explorer "Find handle" feature for it. For example if the directory has a name "b:\qwerty" then perform the search using "b:\qwerty" string. Will any files be found?
#7305
Posted: 08/15/2008 07:28:48
by Volodymyr Zinin (EldoS Corp.)

Also check up whether the OnCanFileBeDeleted callback returns true for the deleted directory.
#7307
Posted: 08/15/2008 07:34:42
by Dan Cooper (Basic support level)
Joined: 06/27/2007
Posts: 125

There are open files in the directory, the files are open by our software as we still have a handle open.

There are no executables actually running but we still maintain an open handle from Explorer.exe as the OnClose event was never called for that file. If I am correct setting CallAllOpenCloseCallbacks to false should mean that we only receive one Open/Close for any given file but in this case we receive 2 Open callbacks but only 1 Close leaving us this open handle.

#7309
Posted: 08/15/2008 07:48:42
by Volodymyr Zinin (EldoS Corp.)

I.e. the OnDeleteFile callback for the directory is called. But you can't delete the directory in this callback because it contains opened files that only will be closed when all OnClose callbacks will be called for them. Am I right?
Also by EldoS: CallbackRegistry
A component to monitor and control Windows registry access and create virtual registry keys.

Reply

Statistics

Topic viewed 25889 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!