共用方式為


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)

備註

使用此方法可藉由新增至目前許可權的狀態來修改對網路資訊的存取。

適用於