''' 为文件添加users,everyone用户组的完全控制权限
''' </summary>
''' <param name="filePath"></param>
Private Shared Sub AddSecurityControll2File(ByVal filePath As String)
'获取文件信息
Dim fileInfo As New IO.FileInfo(filePath)
'获得该文件的访问权限
Dim fileSecurity As System.Security.AccessControl.FileSecurity = fileInfo.GetAccessControl()
'添加ereryone用户组的访问权限规则 完全控制权限
fileSecurity.AddAccessRule(New FileSystemAccessRule("Everyone", FileSystemRights.FullControl, AccessControlType.Allow))
'添加Users用户组的访问权限规则 完全控制权限
fileSecurity.AddAccessRule(New FileSystemAccessRule("Users", FileSystemRights.FullControl, AccessControlType.Allow))
'设置访问权限
fileInfo.SetAccessControl(fileSecurity)
End Sub
|
暂时没有评论
发表评论 - 不要忘了输入验证码哦! |