共用方式為


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)

適用於