ConfigurationLocation Class

 
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.

Represents a location element within a configuration file.

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

System.Object
  System.Configuration.ConfigurationLocation

Public Class ConfigurationLocation

NameDescription
System_CAPS_pubpropertyPath

Gets the relative path to the resource whose configuration settings are represented by this ConfigurationLocation object.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodOpenConfiguration()

This API supports the product infrastructure and is not intended to be used directly from your code. Creates an instance of a Configuration object.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

An instance of the ConfigurationLocation class represents a single location element within a configuration file. Locations are used to specify configuration settings that apply only to a specified resource, such as a specific page, file, or subdirectory, within your Web application. Use the ConfigurationLocation class to obtain the path and the Configuration object that applies to the specified resource.

In the following code example, the Web configuration for the application MySampleApp is loaded, and then the locations defined in the configuration are displayed.

Imports System
Imports System.Collections
Imports System.Configuration

Class DisplayLocationInfo
    Public Overloads Shared Sub Main()
        Dim config As System.Configuration.Configuration = _
            ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
        Dim myLocationCollection As _
            System.Configuration.ConfigurationLocationCollection = config.Locations
        Dim myLocation As ConfigurationLocation
        For Each myLocation In  myLocationCollection
            Console.WriteLine("Location Path: {0}", myLocation.Path)
            Dim myLocationConfiguration As System.Configuration.Configuration = _
                myLocation.OpenConfiguration()
            Console.WriteLine("Location Configuration Path: {0}", _
                myLocationConfiguration.FilePath)
        Next myLocation
        Console.WriteLine("Done...")
        Console.ReadLine()
    End Sub
End Class 'DisplayLocationInfo

.NET Framework
Available since 2.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: