Setting ACE
is very slow for folder with many files and subfolders. My folder has 35602 files and 648 subfolders and SetAccessControl method needs 30 minute to remove a user from this folder.
I am removing a
user from the security tab of folder using following code.
DirectoryInfo dirInfo
= new DirectoryInfo(folderPath); DirectorySecurity fSecurity = dirInfo.GetAccessControl(AccessControlSections.All); fSecurity = CanonicalizeDacl(fSecurity);
fSecurity
.RemoveAccessRule(new FileSystemAccessRule(coworkerAccount, accessRight, AccessControlType.Allow));
dirInfo
.SetAccessControl(fSecurity);
SetAccessControl method takes a long
time when the folder having many files.