This documentation is archived and is not being maintained.

RegistryPermission.AddPathList Method (RegistryPermissionAccess, String)

Adds access for the specified registry variables to the existing state of the permission.

Namespace:  System.Security.Permissions
Assembly:  mscorlib (in mscorlib.dll)

public void AddPathList(
	RegistryPermissionAccess access,
	string pathList


Type: System.Security.Permissions.RegistryPermissionAccess
One of the RegistryPermissionAccess values.
Type: System.String
A list of registry variables (semicolon-separated).


The access parameter is not a valid value of RegistryPermissionAccess.


The pathList parameter is not a valid string.

Use this method to modify access to registry variables by adding to the state of the current permission object.

The following code example shows the use of the AddPathList(RegistryPermissionAccess, String) method.

// AddPathList adds access for the specified registry variables to the existing state of the permission.
// SetPathList sets new access for the specified registry variable names to the existing state of the permission.
// GetPathList gets paths for all registry variables with the specified RegistryPermissionAccess.
private static bool SetGetPathListDemo()
        RegistryPermission readPerm1;
        Console.WriteLine("Creating RegistryPermission with AllAccess rights for 'HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0'");
        readPerm1 = new RegistryPermission(RegistryPermissionAccess.AllAccess, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
        Console.WriteLine("Adding 'HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION' to the write access list, "
            + "and \n 'HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\FloatingPointProcessor\\0' "
            + "to the read access list.");
        readPerm1.AddPathList(RegistryPermissionAccess.Write, "HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION");
        Console.WriteLine("Read access list before SetPathList = " +
        Console.WriteLine("Setting read access rights to \n'HKEY_LOCAL_MACHINE\\HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0'");
        Console.WriteLine("Read access list after SetPathList = \n" +
        Console.WriteLine("Write access = \n" +
        Console.WriteLine("Write access Registry variables = \n" +
    catch (ArgumentException e)
        // RegistryPermissionAccess.AllAccess can not be used as a parameter for GetPathList.
        Console.WriteLine("An ArgumentException occured as a result of using AllAccess. "
            + "AllAccess cannot be used as a parameter in GetPathList because it represents more than one "
            + "type of registry variable access : \n" + e);

    return true;

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.