0
我在ACL中爲我的文件夾添加組,但我無法選中/取消選中它。加入ACL:如何選中或取消選中選項
String account = @"HYPROSTROY\Все сотрудники";
FileSystemRights rights = FileSystemRights.FullControl;
// I have tried and it too:
// FileSystemRights rights = FileSystemRights.Read | FileSystemRights.Write | FileSystemRights.Modify;
AccessControlType controlType = AccessControlType.Allow;
DirectorySecurity security = local_commonDir.Parent.GetAccessControl(AccessControlSections.Access);
FileSystemAccessRule rule = new FileSystemAccessRule(account, rights, controlType);
security.AddAccessRule(rule);
// local_commonDir - экземпляр DirectoryInfo
local_commonDir.Parent.SetAccessControl(security);
組,但所有選項都選中:
UPD === 我有嘗試其他方法:
// String account = Path.Combine(Environment.MachineName, "Пользователи");
String account = @"HYPROSTROY\Все сотрудники";
FileSystemRights rights = FileSystemRights.FullControl;
AccessControlType controlType = AccessControlType.Allow;
DirectorySecurity security = local_commonDir.Parent.GetAccessControl(AccessControlSections.All);
FileSystemAccessRule rule = new FileSystemAccessRule(account, rights, controlType);
//security.AddAccessRule(rule);
Boolean result;
security.ModifyAccessRule(AccessControlModification.Add, rule, out result);
local_commonDir.Parent.SetAccessControl(security);
但選項未被選中:(
我的錯誤在哪裏?
但它不是workong我。 :( –
這裏也是msdn的示例... http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.setaccesscontrol%28v=vs.90%29.aspx, 但是我在本文中看到http://msdn.microsoft.com/en-us/library/t1h6d4k4%28v=vs.90%29.aspx以下內容:調用此方法重載相當於調用GetAccessControl方法重載並指定訪問控制部分AccessControlSections.Access | AccessControlSections.Owner | AccessControlSections.Group – JJschk
看看我的「UPD」。我也試過使用'ModifyAccessRule',但它不幫助我。 –