共用方式為


SectionInformation.IsProtected 屬性

定義

取得值,指出關聯的組態區段是否屬於受保護。

public:
 property bool IsProtected { bool get(); };
public bool IsProtected { get; }
member this.IsProtected : bool
Public ReadOnly Property IsProtected As Boolean

屬性值

如果這個 ConfigurationSection 已受到保護,則為 true,否則為 false。 預設為 false

範例

本節中的範例示範如何在存取組態檔中的相關區段信息之後取得 IsProtected 屬性值。

下列範例會 SectionInformation 取得物件。

// Get the current configuration file.
System.Configuration.Configuration config =
        ConfigurationManager.OpenExeConfiguration(
        ConfigurationUserLevel.None);

// Get the section.
UrlsSection section =
    (UrlsSection)config.GetSection("MyUrls");

SectionInformation sInfo =
    section.SectionInformation;
' Get the current configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)

' Get the section.
Dim section As UrlsSection = _
CType(config.GetSection("MyUrls"), UrlsSection)
        
Dim sInfo As SectionInformation = _
section.SectionInformation

下列範例會取得 IsProtected 值。

bool protect =
    sInfo.IsProtected;
Console.WriteLine("Section protected?: {0}",
    protect.ToString());
Dim protect As Boolean = _
sInfo.IsProtected
Console.WriteLine("Section protected?: {0}", _
protect.ToString())

備註

受保護的組態區段會加密和唯讀。

如需受保護組態區段的詳細資訊,請參閱 使用受保護的組態加密組態資訊

適用於

另請參閱