C#指定某用户对某文夹件的访问权限


      using System.Security.AccessControl;

                //设置myFloder文件夹的iis访问权限
                string userAccount = @"IIS_IUSRS";
                string filePath = @"C:\inetpub\myFloder";
                DirectorySecurity dSecurity = Directory.GetAccessControl(filePath,
                        AccessControlSections.All);

                dSecurity.AddAccessRule(new FileSystemAccessRule(userAccount,
                                       FileSystemRights.FullControl,
                                       InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit,
                                       PropagationFlags.None,
                                       AccessControlType.Allow));
                Directory.SetAccessControl(filePath, dSecurity);

posted @ 2016-01-04 17:12  beautifulday  阅读(381)  评论(0编辑  收藏  举报