EldoS | Feel safer!

Software components for data protection, secure storage and transfer

preventing folder/s deletion question

Posted: 10/25/2011 07:44:30
by ohad (Standard support level)
Joined: 02/02/2011
Posts: 24


This question is related to an old forum posting here:


We are now facing the exact same problem,that is,we would like to have a group of folders "un-deleteable" from outside,while also preserving their file contents but at the same time allow users to manipulate those files while they are within said folder.

Since I did not see a definitive answer given at the end of that old posting I would like to ask if this is indeed in some way possible with CBFS?

Thanks a lot for your help.
Posted: 10/25/2011 11:40:02
by Volodymyr Zinin (Team)

A folder can't be deleted while it contains anything inside (files, directories). If you want to protect an empty directory from deletion then just not delete it from your OnDeleteFile callback.
Also there is the OnCanFileBeDeleted callback which can help to prohibit the deletion.
Posted: 10/26/2011 07:52:04
by ohad (Standard support level)
Joined: 02/02/2011
Posts: 24

I understand what you are saying.

However in our case the folder is not empty.

When we try to delete a folder with content in it,firstly all the content gets deleted and then the folder itself,as per Windows behavior,we would like to avoid that for certain folders.

However at the same time we would like to allow the users to deleted those same files when they are inside the folder.

With the OnCanFileBeDeleted callback it seems I can't really distinguish whether I'm deleting the folder from the outside and thus all the files in it as well,or if I am inside that folder and attempt deleting those files.
Posted: 10/26/2011 08:31:02
by Eugene Mayevski (Team)

This is technically not possible. There's no such operation as "delete directory with contents". On filesystem level first all files are deleted and then the command to delete the empty directory is sent.

Sincerely yours
Eugene Mayevski
Posted: 10/26/2011 09:37:09
by ohad (Standard support level)
Joined: 02/02/2011
Posts: 24

Ok,but in Windows 7 at least I can in fact set the permissions of a folder in such a way that I will not be able to delete the folder and the files within it and yet when I enter the folder I can delete the files.

So this scenario is actually possible.
Posted: 10/26/2011 10:09:20
by Eugene Mayevski (Team)

Scenario might be possible, but on file system level it doesn't exist.

Sincerely yours
Eugene Mayevski
Posted: 10/26/2011 11:51:38
by ohad (Standard support level)
Joined: 02/02/2011
Posts: 24

I see,so just to clarify this means that it is not possible with the CBFS then?

Posted: 10/26/2011 12:00:39
by Volodymyr Zinin (Team)

If returning false from the OnCanFileBeDeleted callback for the directory or ignoring its deletion in the OnDelete callback don't help then it isn't.
Posted: 10/26/2011 12:08:41
by Eugene Mayevski (Team)

It is not possible anywhere. What you expect to be possible only works in Explorer, but anybody can use some third-party file manager and delete the folder with all files in it. Or you can write the code that will do the same.

I remember this topic discussed a year or two ago and there was no solution found then either. So you need to reconsider your requirements and design in this aspect.

Sincerely yours
Eugene Mayevski
Posted: 10/26/2011 12:47:45
by Eric Dahlvang (Standard support level)
Joined: 09/11/2009
Posts: 29

GreenFlower, there is a difference between file attributes and special permissions. The reason you can do this with Windows 7 (and other operating systems) has nothing to do with the underlying file system itself. You would need to set special permissions on the folders you wish to behave like you've described. This can be done programatically, but it doesn't have anything to do with the underlying file system.



Topic viewed 5883 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!