|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Help needed on creating Shared DirectoryPC 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) How about shell("net share sharename=directorypath")?
Regards Simon Show quoteHide quote "mkober" <mko***@wi.rr.com> wrote in message news:1139255585.520977.52650@g44g2000cwa.googlegroups.com... > 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) > Isn't there a more accurate/specific dotnet way to do this, other than
shelling? I could see the need to change the permission levels in the future from ALL to specific domain/group accounts. If this were written at the start for this purpose, it would make life a lot easier. If there was a way to do this, then I'd love to know how!
I'm sure somebody better then us know's a way!! Simon Show quoteHide quote "mkober" <mko***@wi.rr.com> wrote in message news:1139260602.856650.88210@g43g2000cwa.googlegroups.com... > Isn't there a more accurate/specific dotnet way to do this, other than > shelling? > > I could see the need to change the permission levels in the future from > ALL to specific domain/group accounts. If this were written at the > start for this purpose, it would make life a lot easier. > I did try the Shell("Net Share LIMS=C:\LIMS") option in DotNet and it
worked fine, did what I wanted. It still bothers me that I can't find any DotNet way of doing so. I'm still looking into this more.
Lock statement in C#, Is there an equivalent in VB.NET?
For each Windows Shell Integration: how? File is busy convert text to access mdb Structured files in VS 2005 VB.NET - How do I set and keep data in the clipboard? halt application flow until condition is met halt application flow until condition is met Concatenation - String.Concat |
|||||||||||||||||||||||