ConfigurationLocation 類別

定義

表示組態檔內的 location 項目。Represents a location element within a configuration file.

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

範例

在下列程式碼範例中, 會載入應用程式MySampleApp的 Web 設定, 然後顯示在設定中定義的位置。In the following code example, the Web configuration for the application MySampleApp is loaded, and then the locations defined in the configuration are displayed.

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單一元素。An instance of the ConfigurationLocation class represents a single location element within a configuration file. 位置是用來指定僅適用于您 Web 應用程式內指定之資源的設定, 例如特定頁面、檔案或子目錄。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. 使用類別來取得路徑Configuration和套用至指定資源的物件。 ConfigurationLocationUse the ConfigurationLocation class to obtain the path and the Configuration object that applies to the specified resource.

屬性

Path

取得資源的相對路徑,該資源的組態設定由這個 ConfigurationLocation 物件表示。Gets the relative path to the resource whose configuration settings are represented by this ConfigurationLocation object.

方法

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
OpenConfiguration()

建立 Configuration 物件的執行個體。Creates an instance of a Configuration object.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於