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
public void AddPathList (
	RegistryPermissionAccess access, 
	String pathList
public function AddPathList (
	access : RegistryPermissionAccess, 
	pathList : String
Not applicable.



One of the RegistryPermissionAccess values.


A list of registry variables (semicolon-separated).

Exception typeCondition


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. This code example is part of a larger example provided for the RegistryPermission class.

// 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 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;

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions