NetworkInformationPermission.AddPermission(NetworkInformationAccess) 方法

定义

将指定的值添加到此权限中。

public:
 void AddPermission(System::Net::NetworkInformation::NetworkInformationAccess access);
public void AddPermission (System.Net.NetworkInformation.NetworkInformationAccess access);
member this.AddPermission : System.Net.NetworkInformation.NetworkInformationAccess -> unit
Public Sub AddPermission (access As NetworkInformationAccess)

参数

示例

以下示例创建一个空权限对象,然后将其添加到其中。

System::Net::NetworkInformation::NetworkInformationPermission^ permission = gcnew System::Net::NetworkInformation::NetworkInformationPermission( System::Security::Permissions::PermissionState::None );
permission->AddPermission( System::Net::NetworkInformation::NetworkInformationAccess::Read );
Console::WriteLine( L"Access is {0}", permission->Access );
System.Net.NetworkInformation.NetworkInformationPermission permission =
    new System.Net.NetworkInformation.NetworkInformationPermission(
        System.Security.Permissions.PermissionState.None);
permission.AddPermission(
        System.Net.NetworkInformation.NetworkInformationAccess.Read);
Console.WriteLine("Access is {0}", permission.Access);
Dim permission As New System.Net.NetworkInformation.NetworkInformationPermission( _
    System.Security.Permissions.PermissionState.None)
permission.AddPermission(System.Net.NetworkInformation.NetworkInformationAccess.Read)
Console.WriteLine("Access is {0}", permission.Access)

注解

使用此方法通过将 添加到当前权限的状态来修改对网络信息的访问权限。

适用于