語言

X509SelectionFlag 列舉

定義

指定使用 SelectFromCollection 方法所要求的選取範圍類型。

public enum class X509SelectionFlag
public enum X509SelectionFlag
type X509SelectionFlag = 
Public Enum X509SelectionFlag
繼承
X509SelectionFlag

欄位

名稱 值 Description
SingleSelection 0

只有一個選擇。 使用者介面允許使用者選擇一個 X.509 證書。

MultiSelection 1

多重選擇。 使用者可以使用 SHIFT 或 CRTL 金鑰選擇多個 X.509 憑證。

範例

以下程式碼範例示範如何將選擇旗標與此 X509Certificate2UI.SelectFromCollection 方法搭配使用。 此程式碼範例是本類別更大範例 X509Store 的一部分。 較大的範例會開啟目前使用者的個人憑證儲存庫,允許使用者選擇憑證,然後將憑證及憑證鏈資訊寫入主控台。 輸出取決於使用者選擇的憑證。

    //Create new X509 store from local certificate store.
    X509Store store = new X509Store("MY", StoreLocation.CurrentUser);
    store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);

    //Output store information.
    Console.WriteLine ("Store Information");
    Console.WriteLine ("Number of certificates in the store: {0}", store.Certificates.Count);
    Console.WriteLine ("Store location: {0}", store.Location);
    Console.WriteLine ("Store name: {0} {1}", store.Name, Environment.NewLine);

    //Put certificates from the store into a collection so user can select one.
    X509Certificate2Collection fcollection = (X509Certificate2Collection)store.Certificates;
    X509Certificate2Collection collection = X509Certificate2UI.SelectFromCollection(fcollection, "Select an X509 Certificate", "Choose a certificate to examine.", X509SelectionFlag.SingleSelection);
    X509Certificate2 certificate = collection[0];
    X509Certificate2UI.DisplayCertificate(certificate);
'Create new X509 store from local certificate store.
Dim store As New X509Store("MY", StoreLocation.CurrentUser)
store.Open(OpenFlags.OpenExistingOnly Or OpenFlags.ReadWrite)

'Output store information.
Console.WriteLine("Store Information")
Console.WriteLine("Number of certificates in the store: {0}", store.Certificates.Count)
Console.WriteLine("Store location: {0}", store.Location)
Console.WriteLine("Store name: {0} {1}", store.Name, Environment.NewLine)

'Put certificates from the store into a collection so user can select one.
Dim fcollection As X509Certificate2Collection = CType(store.Certificates, X509Certificate2Collection)
Dim collection As X509Certificate2Collection = X509Certificate2UI.SelectFromCollection(fcollection, "Select an X509 Certificate", "Choose a certificate to examine.", X509SelectionFlag.SingleSelection)
Dim certificate As X509Certificate2 = collection(0)
X509Certificate2UI.DisplayCertificate(certificate)

備註

此旗標代表使用該 X509Certificate2UI.SelectFromCollection 方法進行單一或多重憑證選擇。

適用於