Help needed on creating Shared Directory

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)
 
M

mkober

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.
 
S

Simon Verona

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
 
M

mkober

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top