Hello
You may have to set the InheritanceFlags as well.
Example:
DirectorySecurity dirsec = null;
DirectoryInfo dir = new DirectoryInfo(@"C:\temp");
String identity = "SomeUsername";
dirsec = dir.GetAccessControl(AccessControlSections.Access);
rule = new FileSystemAccessRule(identity, FileSystemRights.FullControl | FileSystemRights.Synchronize, AccessControlType.Allow);
dirsec.AddAccessRule(rule);
rule = new FileSystemAccessRule(identity, FileSystemRights.FullControl | FileSystemRights.Synchronize, InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.InheritOnly, AccessControlType.Allow);
dirsec.AddAccessRule(rule);
dir.SetAccessControl(dirsec);
Also ensure that the user/account running the application has the privileges to set access control.
If you get an exception, feel free to post it :-)
I hope that helps...