How to set full control to a directory??

Posted by smwikipedia on Stack Overflow See other posts from Stack Overflow or by smwikipedia
Published on 2010-05-09T15:28:35Z Indexed on 2010/05/09 15:38 UTC
Read the original article Hit count: 176

Filed under:
|

I am using the following simple code to add full control to a directory, but it doesn't work.

        String dir_name = @"folder_full_path";
        DirectorySecurity dir_security = Directory.GetAccessControl(dir_name);
        FileSystemAccessRule access_rule = new FileSystemAccessRule(@"AccountName",
            FileSystemRights.FullControl, AccessControlType.Allow);
        dSecurity.AddAccessRule(access_rule);
        Directory.SetAccessControl(dir_name, dir_security);

But this code only set special permissions to the target folder. This code is almost the same as the MSDN sample. I am scratching my head for a reasonable explanation... Hope someone could shed some light on me.

Many thanks.

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#