Imports Public key into a custom OpenPGP key store. If the key store does not exist, it is created.

Namespace: DidiSoft.Pgp
Assembly: DidiSoft.Pgp (in DidiSoft.Pgp.dll) Version: 1.7.3.35547

Syntax

C#
public KeyPairInformation ImportPublicKey(
	string publicKeyFileName
)
Visual Basic
Public Function ImportPublicKey ( _
	publicKeyFileName As String _
) As KeyPairInformation
Visual C++
public:
KeyPairInformation^ ImportPublicKey(
	String^ publicKeyFileName
)

Parameters

publicKeyFileName
Type: System..::..String
FileName of the Public key to be imported (absolute or relative path)

Return Value

A KeyPairInformation representing the imported public key

Examples

CopyC#
using System;
using DidiSoft.Pgp;

public class ImportPublicKey
{
   public static void Demo()
   {
       KeyStore keyStore = new KeyStore(@"DataFiles\key.store", "changeit");
       KeyPairInformation key = keyStore.ImportPublicKey(@"public_key.asc");            
   }
}
CopyVB.NET
Imports System
Imports DidiSoft.Pgp

Public Class ImportPublicKey
   Public Shared Sub Demo()
       Dim keyStore As New KeyStore("DataFiles\key.store", "changeit")
       Dim key As KeyPairInformation = keyStore.ImportPublicKey("public_key.asc")
   End Sub
End Class

Exceptions

ExceptionCondition
DidiSoft.Pgp.Exceptions..::..WrongPublicKeyExceptionif there is no OpenPGP public key in the file
System.IO..::..IOExceptionI/O error

See Also