Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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



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 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

© 2015 Microsoft