.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting Folder Permissions using VB.NET

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
2202 Views, 2 Replies

Setting Folder Permissions using VB.NET

I have a small vb.net app that creates a set of project directories and
preloads them with some common forms. It has come to the point where I need
to limit permissions on the root folder, but open permissions on the sub
folders - like this:

G:\ Drive - Everyone = Read & Execute
>>Root Folder - Everyone = Read & Execute
>>>>Subfolder1 - Everone = Full Permissions
>>>>Subfolder2 - Everone = Full Permissions

I'm hoping someone can show me how to do this with my limited programming
skills in VB.NET as my attempts have failed.

Thanks!
2 REPLIES 2
Message 2 of 3
Mikko
in reply to: Anonymous

Maybe somewhere within the:

System.Security.AccessControl
System.Security.Permissions

I don't know if this will work. This stuff gets deep quick.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim DirectoryName As String = "c:\BogusDir"
AddDirectorySecurity(DirectoryName, "YourDOMAIN\YourAccount", FileSystemRights.ReadData, AccessControlType.Allow)
End Sub

Sub AddDirectorySecurity(ByVal FileName As String, ByVal Account As String, ByVal Rights As FileSystemRights, ByVal ControlType As AccessControlType)
Dim di As New IO.DirectoryInfo(FileName)
Dim ds As DirectorySecurity = di.GetAccessControl()
ds.AddAccessRule(New FileSystemAccessRule(Account, Rights, ControlType))
di.SetAccessControl(ds)
End Sub

Best you go to a Microsoft forum and ask this.
Message 3 of 3
Anonymous
in reply to: Anonymous

.NET security will only allow an app to change things
like permissions on folder, if the app is running under
an account that has rights to do that (e.g., an admin).

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2008
Supporting AutoCAD 2000 through 2008
http://www.acadxtabs.com

"pkirill" wrote in message news:5679120@discussion.autodesk.com...
I have a small vb.net app that creates a set of project directories and
preloads them with some common forms. It has come to the point where I need
to limit permissions on the root folder, but open permissions on the sub
folders - like this:

G:\ Drive - Everyone = Read & Execute
>>Root Folder - Everyone = Read & Execute
>>>>Subfolder1 - Everone = Full Permissions
>>>>Subfolder2 - Everone = Full Permissions

I'm hoping someone can show me how to do this with my limited programming
skills in VB.NET as my attempts have failed.

Thanks!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost