Link to home
Start Free TrialLog in
Avatar of soousky
soousky

asked on

How to set/change folder permission in VB .NET 3.5

Hi,

I am trying to change a folder (and all its sub folders and files) permission in Visual studio 2008 and VB .Net 3.5. Also I can not use windows AD as it is not implemented.

What is the best way to do this?

I have looked around and there is some information about setting file/folder permissions s but its all older stuff and I hear there is new way to do this in VS 2008. But I can not find it.

What I want to do it change a folder (and all files and sub files) permission to full access do stuff and then change it to read only and execute.

I am doing this using Visual Basic and .NET 3.5.

Thanks


ASKER CERTIFIED SOLUTION
Avatar of melmers
melmers
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of soousky
soousky

ASKER

Thanks
Good code, just one comment, this line needs to have a comma after UserName:
myRule = New FileSystemAccessRule(UserName myRuleValue, InheritanceFlags.ContainerInherit Or InheritanceFlags.ObjectInherit Or InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow)
dSecInfo.AddAccessRule(myRule)
dSecInfo.SetAccessRule(myRule)
dInfo.SetAccessControl(dSecInfo)
Open in New Window Select All
This worked great!