CertificateCollectionContains Method |
Checks whether the specified certificate is contained in the collection or not.
Namespace: MailBee.SecurityAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public bool Contains(
Certificate cert
)
Public Function Contains (
cert As Certificate
) As Boolean
Parameters
- cert
- Type: MailBee.SecurityCertificate
The certificate that should be checked.
Return Value
Type:
Booleantrue if the certificate was found in the collection; otherwise,
false.
Examples This sample adds the certificate to the collection if it's not already present there.
using MailBee.Security;
Certificate cert = new Certificate(@"C:\Temp\certificate.cer", CertFileType.Cer, null);
CertificateStore store = new CertificateStore(@"C:\Temp\my_store.p7b", CertStoreType.PublicFile, null);
CertificateCollection collection = store.GetAllCertificates();
if (!collection.Contains(cert))
{
store.AddCertificate(cert, false);
}
store.SaveToFile(@"C:\Temp\my_store.p7b", CertStoreFileType.P7b, null);
Imports MailBee.Security
Dim cert As Certificate = New Certificate("C:\Temp\certificate.cer", CertFileType.Cer, Nothing)
Dim store As CertificateStore = New CertificateStore("C:\Temp\my_store.p7b", CertStoreType.PublicFile, Nothing)
Dim Collection As CertificateCollection = store.GetAllCertificates()
If Not Collection.Contains(cert) Then
store.AddCertificate(cert, False)
End If
store.SaveToFile("C:\Temp\my_store.p7b", CertStoreFileType.P7b, Nothing)
See Also