Directory/File Permission Issue

I wrote code to set permission of the folder. Function I developed was

public void SetPermission(string user,FileSystemRights rights)
    DirectoryInfo dInfo = new DirectoryInfo(folderPath);
    DirectorySecurity oDirectorySecurity = new DirectorySecurity();

    oDirectorySecurity.AddAccessRule(new FileSystemAccessRule(user, rights, AccessControlType.Allow));

This function is working fine to set permission for the user. But when I check folder Properties -> Security , user added. But no permission is checked in checkbox Open Advanced dialogbox. In this box I can see permission , which i set for the user.

So my question is Why there is no checkbox seleced on security tab, but it is there in advanced tab?

Please HELP me!!!!!!


I ran into this as well. It seems to be a Service Patch thing.

You can read how I fixed it at

The short version: You have to set a flag for all of the ACLs for all users. Yes... it's ugly. And when you add Service Pack 3, the checkmarks go away again. If anyone has a cleaner solution than this, PLEASE let me know.

I have code for that on my site.

UPDATE: The URL now points to the new site.

It might help to use dInfo.GetAccessControl to initialize oDirectorySecurity. You could also try calling oDirectorySecurity.SetOwner.

Sometimes permissions only show up in advanced if they are not applied to to correct objects. Try setting the Inheritance/Propigation flags on your FileSystemAccessRule object.

Need Your Help

XC32 migrating from 1.32 to 1.34

c embedded legacy mplab pic32

I'm using XC32 and MPLABX for work. After a year of projects I've decided to try to upgrade to new XC32 version. I've seen that legacy libraries like plib are no longer supported and I'd like to kn...

How to add something complicated as a Resource or a Setting to a program?

c# resources persistence settings

If I want to add a string as a setting or an image as a resource – I do it through Visual Studio.