title: Unable to remove folder permissions (access rules) using DirectorySecurity facilities
body: <p>I know there are a lot of posts out there about removing permissions on a folder. </p>
  
  <p>However each one I try seems to leave the user groups intact and no exception is thrown - the rules are removed from ACL and the modified AccessControl is set successfully but no actual changes are made. </p>
  
  <p>I need to straight out CLEAR the folder's permission list. I want the folder to be empty after.</p>
  
  <p>Example:</p>
  
  <p>This:</p>
  
  <p><img src="https://i.stack.imgur.com/pUKLD.png" alt="properties"></p>
  
  <p>Should become:</p>
  
  <p><img src="https://i.stack.imgur.com/iWzyr.png" alt="Cleared Properties"></p>
  
  <p>This is what I am currently trying without success:</p>
  
  <pre><code>DirectorySecurity objSecObj = directory.GetAccessControl();
                  AuthorizationRuleCollection acl = objSecObj.GetAccessRules(true, true,
                                              typeof(System.Security.Principal.NTAccount));
  objSecObj.SetAccessRuleProtection(false,false);
  // EDIT: The above line was the problem, first param should be true.
  
  
  foreach (FileSystemAccessRule ace in acl)
  {
        objSecObj.RemoveAccessRuleSpecific(ace);
  }
  directory.SetAccessControl(objSecObj);
  </code></pre>
  
  <p>The intent is to remove all users, then manually add specific user groups after the fact. That part is not an issue, removing the current users is where I am having trouble.</p>