-- 作者:有点甜
-- 发布时间:2018/3/21 18:09:00
--
我这样测试没问题
Dim dirPath = "d:\\test" Dim dir As New io.DirectoryInfo(dirPath) Dim dirSecurity As System.Security.AccessControl.DirectorySecurity = dir.GetAccessControl(System.Security.AccessControl.AccessControlSections.All) Dim [inherits] As System.Security.AccessControl.InheritanceFlags = System.Security.AccessControl.InheritanceFlags.ContainerInherit Or System.Security.AccessControl.InheritanceFlags.ObjectInherit Dim everyoneFileSystemAccessRule As System.Security.AccessControl.FileSystemAccessRule = New System.Security.AccessControl.FileSystemAccessRule("Everyone", System.Security.AccessControl.FileSystemRights.FullControl, [inherits], System.Security.AccessControl.PropagationFlags.None, System.Security.AccessControl.AccessControlType.Allow) Dim usersFileSystemAccessRule As System.Security.AccessControl.FileSystemAccessRule = New System.Security.AccessControl.FileSystemAccessRule("Users", System.Security.AccessControl.FileSystemRights.FullControl, [inherits], System.Security.AccessControl.PropagationFlags.None, System.Security.AccessControl.AccessControlType.Allow) Dim isModified As Boolean = False dirSecurity.ModifyAccessRule( System.Security.AccessControl.AccessControlModification.Add, everyoneFileSystemAccessRule, isModified) dirSecurity.ModifyAccessRule( System.Security.AccessControl.AccessControlModification.Add, usersFileSystemAccessRule, isModified) dir.SetAccessControl(dirSecurity)
|