ElementInformation.Source 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得關聯 ConfigurationElement 物件所源自的原始程式檔。
public:
property System::String ^ Source { System::String ^ get(); };
public string Source { get; }
member this.Source : string
Public ReadOnly Property Source As String
屬性值
關聯 ConfigurationElement 物件所源自的原始程式檔。
範例
下列範例將示範如何使用 Source 屬性。
static public void GetElementSource()
{
// Get the current configuration file.
System.Configuration.Configuration config =
ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None);
// Get the section.
UrlsSection section =
(UrlsSection)config.GetSection("MyUrls");
// Get the element.
UrlConfigElement url = section.Simple;
// Get the element source file.
string sourceFile =
url.ElementInformation.Source;
Console.WriteLine("Url element source file: {0}",
sourceFile);
}
Public Shared Sub GetElementSource()
' Get the current configuration file.
Dim config _
As System.Configuration.Configuration = _
ConfigurationManager.OpenExeConfiguration( _
ConfigurationUserLevel.None)
' Get the section.
Dim section As UrlsSection = _
CType(config.GetSection("MyUrls"), UrlsSection)
' Get the element.
Dim url As UrlConfigElement = _
section.Simple
' Get the element source file.
Dim sourceFile As String = _
url.ElementInformation.Source
Console.WriteLine( _
"Url element source file: {0}", sourceFile)
End Sub
備註
ConfigurationElement物件可能會以默認狀態建立,在此情況下,這個屬性會傳null
回 。