X509Certificate2 cert = new X509Certificate2("cert.pfx"); byte[] certData = cert.Export(X509ContentType.Cert);
X509Certificate2 cert = new X509Certificate2("cert.pfx"); File.WriteAllBytes("cert.cer", cert.Export(X509ContentType.Cert));In this example, the certificate is loaded from a PFX file and then exported to a file using the Export method with the X509ContentType.Cert format. The WriteAllBytes method is then used to write the byte array to a file named "cert.cer". The System.Security.Cryptography.X509Certificates library in C# is part of the .NET Framework.