By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,558 Members | 1,699 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,558 IT Pros & Developers. It's quick & easy.

Help needed on creating Shared Directory

P: n/a
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)

Feb 6 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
How about shell("net share sharename=directorypath")?

Regards
Simon

"mkober" <mk****@wi.rr.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.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)

Feb 6 '06 #2

P: n/a
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.

Feb 6 '06 #3

P: n/a
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
"mkober" <mk****@wi.rr.com> wrote in message
news:11*********************@g43g2000cwa.googlegro ups.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.

Feb 6 '06 #4

P: n/a
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.

Feb 7 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.