Export (0) Print
Expand All

EnvironmentPermission.AddPathList Method

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

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

public void AddPathList (
	EnvironmentPermissionAccess flag,
	string pathList
)
public void AddPathList (
	EnvironmentPermissionAccess flag, 
	String pathList
)
public function AddPathList (
	flag : EnvironmentPermissionAccess, 
	pathList : String
)
Not applicable.

Parameters

flag

One of the EnvironmentPermissionAccess values.

pathList

A list of environment variables (semicolon-separated).

Exception typeCondition

ArgumentNullException

The pathList parameter is a null reference (Nothing in Visual Basic).

ArgumentException

The flag parameter is not a valid value of EnvironmentPermissionAccess.

Use this method to modify environment variable access by adding to the state of the current permission.

The following code example shows the use of the AddPathList method. This code example is part of a larger example provided for the EnvironmentPermission class.

private bool SetGetPathListDemo()
{
    try
    {
        Console.WriteLine("********************************************************\n");
        Console.WriteLine("Creating an EnvironmentPermission with AllAccess rights for 'TMP'");
        EnvironmentPermission envPerm1 = new EnvironmentPermission(EnvironmentPermissionAccess.AllAccess, "TMP");
        Console.WriteLine("Adding 'TEMP' to the write access list, and 'windir' to the read access list.");
        envPerm1.AddPathList(EnvironmentPermissionAccess.Write, "TEMP");
        envPerm1.AddPathList(EnvironmentPermissionAccess.Read, "windir");
        Console.WriteLine("Read access list before SetPathList = "
            + envPerm1.GetPathList(EnvironmentPermissionAccess.Read));
        Console.WriteLine("Setting read access to 'TMP'");
        envPerm1.SetPathList(EnvironmentPermissionAccess.Read, "TMP");
        Console.WriteLine("Read access list after SetPathList = "
            + envPerm1.GetPathList(EnvironmentPermissionAccess.Read));
        Console.WriteLine("Write access list = " + envPerm1.GetPathList(EnvironmentPermissionAccess.Write));
        Console.WriteLine("Write access environment variables = "
            + envPerm1.GetPathList(EnvironmentPermissionAccess.AllAccess));
    }
    catch (ArgumentException e)
    {
        // EnvironmentPermissionAccess.AllAccess cannot be used as a parameter for GetPathList.
        Console.WriteLine("An ArgumentException occurred as a result of using AllAccess. "
            + " This property cannot be used as a parameter in GetPathList, because it represents "
            + "more than one type of environment variable : \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

ADD
Show:
© 2015 Microsoft