M
mkober
Can anyone help with the VB.net code needed to create a directory on a
PC and set the share to Everyone with Full Access rights?
I can create the directory, and also set security as desired, but can't
find how to set the share programmatically using framework 2.0.
Thanks in advance!
Here's what I've got (and works):
'Set Directory (using new VB My.Computer option):
My.Computer.FileSystem.CreateDirectory("C:\LIMS")
'Set Security:
Dim security As DirectorySecurity =
System.IO.Directory.GetAccessControl("C:\LIMS")
' Set rule for Everyone
Dim ruleEveryone As FileSystemAccessRule = New
FileSystemAccessRule(New NTAccount("", "Everyone"),
(FileSystemRights.FullControl), (InheritanceFlags.ContainerInherit Or
InheritanceFlags.ObjectInherit), PropagationFlags.None,
AccessControlType.Allow)
' Add the rules to the existing security settings
security.AddAccessRule(ruleEveryone)
' Persist the changes
System.IO.Directory.SetAccessControl("C:\LIMS", security)
PC and set the share to Everyone with Full Access rights?
I can create the directory, and also set security as desired, but can't
find how to set the share programmatically using framework 2.0.
Thanks in advance!
Here's what I've got (and works):
'Set Directory (using new VB My.Computer option):
My.Computer.FileSystem.CreateDirectory("C:\LIMS")
'Set Security:
Dim security As DirectorySecurity =
System.IO.Directory.GetAccessControl("C:\LIMS")
' Set rule for Everyone
Dim ruleEveryone As FileSystemAccessRule = New
FileSystemAccessRule(New NTAccount("", "Everyone"),
(FileSystemRights.FullControl), (InheritanceFlags.ContainerInherit Or
InheritanceFlags.ObjectInherit), PropagationFlags.None,
AccessControlType.Allow)
' Add the rules to the existing security settings
security.AddAccessRule(ruleEveryone)
' Persist the changes
System.IO.Directory.SetAccessControl("C:\LIMS", security)