Deletes the first private key from this key store that has the specified User Id.

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

Syntax

C#
public virtual bool DeletePrivateKey(
	string userId
)
Visual Basic
Public Overridable Function DeletePrivateKey ( _
	userId As String _
) As Boolean
Visual C++
public:
virtual bool DeletePrivateKey(
	String^ userId
)

Parameters

userId
Type: System..::..String
User Id of the form "name (comment) <email address>"

Return Value

true if the key is deleted, false if there is no key with the specified User Id

Remarks

If more than one key exist with the supplied User Id, only the first one is affected.
If no key exists with the specified User Id, no changes to the key store occurs.
This method is equivalent to the GnuPG commands:
gpg --delete-secret-keys [userId]

Examples

CopyC#
using System;
using DidiSoft.Pgp;

public class DeletePrivateKey
{
   public static void Demo()
   {
       KeyStore ks = new KeyStore("pgp.keystore", "changeit");
       ks.DeletePrivateKey("test@gmail.com");            
   }
}
CopyVB.NET
Imports System
Imports DidiSoft.Pgp

Public Class DeletePrivateKey
   Public Shared Sub Demo()
       Dim ks As New KeyStore("pgp.keystore", "changeit")
       ks.DeletePrivateKey("test@gmail.com")
   End Sub
End Class

See Also