C#修改文件或文件夹的权限,为指定用户、用户组添加完全控制权限

C#修改文件或文件夹的权限,为指定用户、用户组添加完全控制权限

 public  void SetFileRole(string foldPath)
        {
            DirectorySecurity fsec = new DirectorySecurity();
            fsec.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl,
                InheritanceFlags.ContainerInherit | InheritanceFlags.ObjectInherit, PropagationFlags.None, AccessControlType.Allow));
            System.IO.Directory.SetAccessControl(foldPath, fsec);
        } 
原文地址:https://www.cnblogs.com/yplong/p/3745610.html