I am trying to set the permissions of a folder and all of it's children on a vista computer. The code I have so far is this.
public static void SetPermissions(string dir)
{
DirectoryInfo info = new DirectoryInfo(dir);
DirectorySecurity ds = info.GetAccessControl();
ds.AddAccessRule(new FileSystemAccessRule(@"BUILTIN\Users",
FileSystemRights.FullControl,
InheritanceFlags.ContainerInherit,
PropagationFlags.None,
AccessControlType.Allow));
info.SetAccessControl(ds);
}
However it's not working as I would expect it to.
Even if I run the code as administrator it will not set the permissions.
The folder I am working with is located in C:\ProgramData\<my folder> and I can manually change the rights on it just fine.
Any one want to point me in the right direction.