Exports private key from this OpenPGP key store into a file.

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

Syntax

C#
public virtual void ExportPrivateKey(
	string fileName,
	string userId,
	bool asciiArmored
)
Visual Basic
Public Overridable Sub ExportPrivateKey ( _
	fileName As String, _
	userId As String, _
	asciiArmored As Boolean _
)
Visual C++
public:
virtual void ExportPrivateKey(
	String^ fileName, 
	String^ userId, 
	bool asciiArmored
)

Parameters

fileName
Type: System..::..String
File name where the key will be exported (absolute or relative path)
userId
Type: System..::..String
User Id of the form "name (comment) <email address>"
asciiArmored
Type: System..::..Boolean
If true, output is in ASCII armored format

Examples

CopyC#
using System;
using DidiSoft.Pgp;

public class ExportKeys
{
   public void Demo()
   {
       KeyStore ks = new KeyStore(@"C:\Test\key.store", "changeit");
       bool asciiArmored = true;
       ks.ExportPrivateKey(@"C:\Test\private_key_exported.pkr", "support@didisoft.com", asciiArmored);
   }
}
CopyVB.NET
Imports System
Imports DidiSoft.Pgp

Public Class ExportKeys
   Public Sub Demo()
       Dim ks As New KeyStore("C:\Test\key.store", "changeit")
       Dim asciiArmored As Boolean = True
       ks.ExportPrivateKey("C:\Test\private_key_exported.pkr", "support@didisoft.com", asciiArmored)
   End Sub
End Class

Exceptions

ExceptionCondition
DidiSoft.Pgp.Exceptions..::..WrongPrivateKeyExceptionIf there is no private key in this key pair
System.IO..::..IOExceptionif an I/O error occurs.

See Also