EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Question about delete file

Posted: 02/25/2013 03:33:54
by Davide Baccaglini (Standard support level)
Joined: 11/19/2012
Posts: 48

Hello, I've a question about deleting file.

I've created a virtual storage (stDisk) and a I tried to delete files and folders.

I've created a folder ('My Folder') with 3 files.
If I try to select these 3 files and delete it I expect that OnDeleteFile event is fired 3 times: it works fine.

But if I try to delete the entire folder ('My Folder') I expect that OnDeleteFile event is fired only one time, only for folder and not for files, but indeed is fired 4 times, 3 for files and 1 for folder.

It's right?

Thanks in advance,
Posted: 02/25/2013 03:42:30
by Eugene Mayevski (Team)

Sorry, you are not. Each file is deleted separately. In Windows API, if you try to delete non-empty directory, you will get an error. The application first clears the directory, then deletes it.

Sincerely yours
Eugene Mayevski
Posted: 02/25/2013 04:15:40
by Davide Baccaglini (Standard support level)
Joined: 11/19/2012
Posts: 48

Thank you Eugene, I've another question.

In my application I manage a RecycleBin folder and when user delete a non-empty directory ('MyFolder') I want to display only 'MyFolder' and not deleted files previously contained in it (similar to the behavior of Windows's RecycleBin).

So, there is a way to understand if a delete operation on a file is originated from a single deleting operation or from a deleting operaton of file parent directory?

Posted: 02/25/2013 04:58:23
by Eugene Mayevski (Team)

In general, it's not possible. While Explorer sends CanFileBeDeleted request for the directory, Explorer is not the only application in the world to manage files.

Sincerely yours
Eugene Mayevski
Posted: 02/25/2013 05:16:41
by Volodymyr Zinin (Team)

Perhaps only by use of "heuristic" methods. For example to learn a behavior how "file explorer" (explorer.exe) deletes non-empty directories and then use it to define whether a nonempty folder is deleted. Take Process Monitor from sysinternals.com to see what I/O requests come during such process from different programs (from explorer.exe as well as from other file managers). Most of such requests are easily correlate with CallbackFS callbacks.
But the usual way for deletion is the following - the contents of a folder is enumerated, the "read-only" attribute is cleared for all files and subfolders (if it's set), then they are deleted, and only then the original folder is deleted.

BTW deletion to recycle bin is not really a deletion but renaming and moving files/folders to a special "recycle bin" folder.



Topic viewed 1338 times

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


Back to top

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

Got it!