System.Configuration.ConfigurationLocation 类

方法描述

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

语法定义(C# System.Configuration.ConfigurationLocation 类 的用法)

public class ConfigurationLocation

构造函数

构造函数名称 构造函数描述

成员/方法

方法名称 方法描述
Equals(Object) 确定指定的 Object 是否等于当前的 Object。 (继承自 Object。)
Finalize 允许对象在“垃圾回收”回收之前尝试释放资源并执行其他清理操作。 (继承自 Object。)
GetHashCode 用作特定类型的哈希函数。 (继承自 Object。)
GetType 获取当前实例的 Type。 (继承自 Object。)
MemberwiseClone 创建当前 Object 的浅表副本。 (继承自 Object。)
OpenConfiguration 基础结构。创建 Configuration 对象的实例。
ToString 返回表示当前对象的字符串。 (继承自 Object。)

提示和注释

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

Topic

Location

如何:使用位置设置配置特定目录配置 ASP .NET Web 应用程序

如何:使用位置设置配置特定目录在 Visual Studio 中生成 ASP .NET Web 应用程序

如何:使用位置设置配置特定目录在 Visual Studio 中生成 ASP .NET Web 应用程序

System.Configuration.ConfigurationLocation 类例子

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

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();
    }
}

继承层次结构

System.Object

System.Configuration.ConfigurationLocation

命名空间

namespace: System.Configuration

程序集: System.Configuration(在 System.Configuration.dll 中)

线程安全

此类型的任何公共 static(在 Visual Basic 中为 Shared) 成员都是线程安全的。但不保证所有实例成员都是线程安全的。

版本信息

.NET Framework 受以下版本支持:4、3.5、3.0、2.0 .NET Framework Client Profile 受以下版本支持:4、3.5 SP1

适用平台

Windows 7, Windows Vista SP1 或更高版本, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008(不支持服务器核心), Windows Server 2008 R2(支持 SP1 或更高版本的服务器核心), Windows Server 2003 SP2 .NET Framework 并不是对每个平台的所有版本都提供支持。有关支持的版本的列表,请参见.NET Framework 系统要求。