changing the user group permission to full control.

Sep 6, 2010 at 11:37 AM

hi all,

i have a requirement to change the permission of  group  (windows\users)  to full control using C# to some set of application folder.

i mean, if u right click on any folder properties, in security tab, u have Users Group.

for this i need to give full control permission programatically.



List<string> users = new List<string>();


SelectQuery Squery = new SelectQuery("Win32_Group", "Domain='" + System.Environment.MachineName.ToString() + "'");


ManagementObjectSearcher mos = new ManagementObjectSearcher(Squery);


foreach (ManagementObject mobj in mos.Get())









FileStream fs = new FileStream("FolderPath.txt", FileMode.Open, FileAccess.Read);


StreamReader reader = new StreamReader(fs);


while ((strFolderpath = reader.ReadLine()) != null)



for (int i = 0; i < users.Count(); i++)



DirectoryInfo myDirectoryinfo = new DirectoryInfo(strFolderpath.ToString());


DirectorySecurity mydirectorySec = myDirectoryinfo.GetAccessControl();


string user = System.Environment.MachineName + '\\' + users[i].ToString();


new FileSystemAccessRule(user, FileSystemRights.FullControl, AccessControlType.Allow));




trying to do like this but i think we cannot pass user group, may be we need to pass user name.

need solution.

please help.

thank you.