ElementInformation.IsLocked Property

 

Gets a value that indicates whether the associated ConfigurationElement object cannot be modified.

Namespace:   System.Configuration
Assembly:  System.Configuration (in System.Configuration.dll)

public bool IsLocked { get; }

Property Value

Type: System.Boolean

true if the associated ConfigurationElement object cannot be modified; otherwise, false.

The IsLocked property returns true when the related element is locked by the AllowOverride, AllowDefinition, or LockAllAttributesExcept property.

The following example shows how to use the IsLocked property.

static public void IsElementLocked()
{
    // Get the current configuration file.
    System.Configuration.Configuration config =
            ConfigurationManager.OpenExeConfiguration(
            ConfigurationUserLevel.None);

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

    // Get the element.
    UrlConfigElement url = section.Simple;

    bool isLocked =
        url.ElementInformation.IsLocked;
    Console.WriteLine("Url element is locked? {0}",
        isLocked.ToString());

}

.NET Framework
Available since 2.0
Return to top
Show: