public static void SetFilePermission(SPWeb web, SPDocumentLibrary lib, SPUser group) { //改变站点继承权 if (!web.HasUniqueRoleDefinitions) { // web.RoleDefinitions.BreakInheritance(false, false);//复制父站点角色定义并且保持权限 } //站点继承权改变后重新设置状态 web.AllowUnsafeUpdates = true; lib.BreakRoleInheritance(false, false); SPRoleAssignment roleAssignment = new SPRoleAssignment(group); SPRoleDefinition roleDefinition = web.RoleDefinitions.GetByType(SPRoleType.Reader); roleAssignment.RoleDefinitionBindings.Add(roleDefinition); lib.RoleAssignments.Add(roleAssignment); }