X509Certificate.GetEffectiveDateString 方法

定義

傳回這個 X.509v3 憑證的有效日期。Returns the effective date of this X.509v3 certificate.

public:
 virtual System::String ^ GetEffectiveDateString();
public virtual string GetEffectiveDateString ();
abstract member GetEffectiveDateString : unit -> string
override this.GetEffectiveDateString : unit -> string
Public Overridable Function GetEffectiveDateString () As String

傳回

這個 X.509 憑證的有效日期。The effective date for this X.509 certificate.

範例

下列範例會使用 GetEffectiveDateString 方法來取得憑證的生效日期,並將它顯示在主控台中。The following example uses the GetEffectiveDateString method to get the effective date of a certificate and displays it to the console.

using namespace System;
using namespace System::Security::Cryptography::X509Certificates;
int main()
{
   
   // The path to the certificate.
   String^ Certificate = "Certificate.cer";
   
   // Load the certificate into an X509Certificate object.
   X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate );
   
   // Get the value.
   String^ results = cert->GetEffectiveDateString();
   
   // Display the value to the console.
   Console::WriteLine( results );
}


using System;
using System.Security.Cryptography.X509Certificates;


public class X509
{

    public static void Main()
    {

        // The path to the certificate.
        string Certificate =  "Certificate.cer";

        // Load the certificate into an X509Certificate object.
        X509Certificate cert = X509Certificate.CreateFromCertFile(Certificate);

        // Get the value.
        string results = cert.GetEffectiveDateString();
       
        // Display the value to the console.
        Console.WriteLine(results);
  
    }

}
Imports System.Security.Cryptography.X509Certificates




Public Class X509
   
   
   Public Shared Sub Main()
      
      ' The path to the certificate.
      Dim Certificate As String = "Certificate.cer"
      
      ' Load the certificate into an X509Certificate object.
      Dim cert As X509Certificate = X509Certificate.CreateFromCertFile(Certificate)
      
      ' Get the value.
      Dim results As String = cert.GetEffectiveDateString()
      
      ' Display the value to the console.
      Console.WriteLine(results)
   End Sub
End Class 

備註

生效日期是 x.509 憑證被視為有效的日期。The effective date is the date after which the X.509 certificate is considered valid.

GetEffectiveDateString 方法會傳回字串,其中顯示以簡短日期模式格式化的日期,後面接著以完整時間模式格式化的時間。The GetEffectiveDateString method returns a string that shows the date formatted in Short Date Pattern followed by the time formatted in Long Time Pattern. 日期和時間會使用目前的文化特性和時區來格式化。The date and time are formatted using the current culture and time zone.

適用於