EnvironmentPermission.GetPathList(EnvironmentPermissionAccess) Método

Definição

Obtém todas as variáveis de ambiente com o EnvironmentPermissionAccess especificado.Gets all environment variables with the specified EnvironmentPermissionAccess.

public:
 System::String ^ GetPathList(System::Security::Permissions::EnvironmentPermissionAccess flag);
public string GetPathList (System.Security.Permissions.EnvironmentPermissionAccess flag);
member this.GetPathList : System.Security.Permissions.EnvironmentPermissionAccess -> string
Public Function GetPathList (flag As EnvironmentPermissionAccess) As String

Parâmetros

flag
EnvironmentPermissionAccess

Um dos valores EnvironmentPermissionAccess que representa um único tipo de acesso à variável de ambiente.One of the EnvironmentPermissionAccess values that represents a single type of environment variable access.

Retornos

String

Uma lista de variáveis de ambiente (separada por ponto e vírgula) para o sinalizador selecionado.A list of environment variables (semicolon-separated) for the selected flag.

Exceções

flag não é um valor válido de EnvironmentPermissionAccess.flag is not a valid value of EnvironmentPermissionAccess.

- ou --or- flag é AllAccess, que representa mais de um tipo de acesso de variável de ambiente ou NoAccess, que não representa nenhum tipo de acesso de variável de ambiente.flag is AllAccess, which represents more than one type of environment variable access, or NoAccess, which does not represent any type of environment variable access.

Exemplos

O exemplo de código a seguir mostra o uso do GetPathList método.The following code example shows the use of the GetPathList method. Este exemplo de código faz parte de um exemplo maior fornecido para a EnvironmentPermission classe.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;
}
Private Function SetGetPathListDemo() As Boolean 
    Try
        Console.WriteLine("********************************************************" + vbLf)
        Console.WriteLine("Creating an EnvironmentPermission with AllAccess rights for 'TMP'")
        Dim envPerm1 As 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 e As ArgumentException
        ' 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 : " + vbLf + e.Message)
    End Try
    
    Return True

End Function 'SetGetPathListDemo

Comentários

Use este método para obter o estado da permissão atual.Use this method to get the state of the current permission. Para obter o Read e os Estados de acesso, é Write necessário duas chamadas para esse método.To get both Read and Write access states requires two calls to this method.

Observação

O flag parâmetro é limitado aos valores de EnvironmentPermissionAccess , que representam os únicos tipos de acesso de variável de ambiente.The flag parameter is limited to the values of EnvironmentPermissionAccess, which represent single types of environment variable access. Esses valores são Read e Write .Those values are Read and Write. Os valores aceitáveis para não flag incluem NoAccess e AllAccess , que não representam tipos únicos de acesso de variável de ambiente.The values acceptable to flag do not include NoAccess and AllAccess, which do not represent single types of environment variable access.

Aplica-se a