ConfigurationLocation 类

定义

表示配置文件中的 location 元素。

public ref class ConfigurationLocation
public class ConfigurationLocation
type ConfigurationLocation = class
Public Class ConfigurationLocation
继承
ConfigurationLocation

示例

在下面的代码示例中,加载应用程序的 MySampleApp Web 配置,然后显示配置中定义的位置。

using System;
using System.Collections;
using System.Configuration;

class DisplayLocationInfo
{
    static void Main(string[] args)
    {
        Configuration config = 
            ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
        ConfigurationLocationCollection myLocationCollection = config.Locations;
        foreach (ConfigurationLocation myLocation in myLocationCollection)
        {
            Console.WriteLine("Location Path: {0}", myLocation.Path);
            Configuration myLocationConfiguration = myLocation.OpenConfiguration();
            Console.WriteLine("Location Configuration File Path: {0}",
                myLocationConfiguration.FilePath);
        }
        Console.WriteLine("Done...");
        Console.ReadLine();
    }
}
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

注解

类的 ConfigurationLocation 实例表示配置文件中的单个 location 元素。 位置用于指定仅适用于 Web 应用程序中的指定资源(例如特定页面、文件或子目录)的配置设置。 ConfigurationLocation使用 类获取应用于指定资源的路径和Configuration对象。

属性

Path

获取配置设置由此 ConfigurationLocation 对象表示的资源的相对路径。

方法

Equals(Object)

确定指定对象是否等于当前对象。

(继承自 Object)
GetHashCode()

作为默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
OpenConfiguration()

创建 Configuration 对象的实例。

ToString()

返回表示当前对象的字符串。

(继承自 Object)

适用于