ElementInformation.Source Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

Gets the source file where the associated ConfigurationElement object originated.

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

public string Source { get; }

Property Value

Type: System.String

The source file where the associated ConfigurationElement object originated.

A ConfigurationElement object may be created in a default state, in which case this property returns null.

The following example shows how to use the Source property.

static public void GetElementSource()
{
    // 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;

    // Get the element source file.
    string sourceFile =
        url.ElementInformation.Source;

    Console.WriteLine("Url element source file: {0}",
                    sourceFile);

}

.NET Framework
Available since 2.0
Return to top
Show: