Ready to get started with anonymous questions today? It's easy! Learn more.
AddDirectorySecurity((userDirectory), Me.AccountName.Text, FileSystemRights.ReadAndExecute, AccessControlType.Allow)
Sub AddDirectorySecurity(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal ControlType As AccessControlType) ' Get a DirectorySecurity object that represents the current security settings. Dim dSecurity As DirectorySecurity = Directory.GetAccessControl(FileName) ' Add the FileSystemAccessRule to the security settings (**following is one line of code**). dSecurity.AddAccessRule(New FileSystemAccessRule(Account, Rights, (InheritanceFlags.ContainerInherit + InheritanceFlags.ObjectInherit), PropagationFlags.InheritOnly, ControlType)) ' Set the new access settings. dSecurity.SetAccessRuleProtection(True, True) Directory.SetAccessControl(FileName, dSecurity)
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.