Foxtable(狐表)用户栏目专家坐堂 → [求助]如何修改文件夹权限


  共有2196人关注过本帖树形打印复制链接

主题:[求助]如何修改文件夹权限

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By: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)


 回到顶部