以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]如何修改文件夹权限  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=116240)

--  作者:linswcfr
--  发布时间:2018/3/21 17:22:00
--  [求助]如何修改文件夹权限
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目1.foxdb


addpathPower("d:\\test", "everyone", "FullControl")
执行后没有效果....,帮助看下问题在哪

--  作者:有点甜
--  发布时间: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)