Control.TemplateSourceDirectory Vlastnost
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Získá virtuální adresář Page nebo UserControl který obsahuje aktuální server řízení.
public:
virtual property System::String ^ TemplateSourceDirectory { System::String ^ get(); };
[System.ComponentModel.Browsable(false)]
public virtual string TemplateSourceDirectory { get; }
[<System.ComponentModel.Browsable(false)>]
member this.TemplateSourceDirectory : string
Public Overridable ReadOnly Property TemplateSourceDirectory As String
Hodnota vlastnosti
Virtuální adresář stránky nebo uživatelského ovládacího prvku, který obsahuje ovládací prvek serveru.
- Atributy
Příklady
Následující příklad používá TemplateSourceDirectory vlastnost dvakrát. Při prvním použití ve Control.MapPathSecure volání metody k získání cesty k adresáři, ve kterém se ovládací prvek nachází. Druhým voláním Directory.GetFiles metody získáte seznam všech souborů obsažených v tomto adresáři.
// An HttpException occurs if the server control does not,;
// have permissions to read the resulting mapped file.
output.Write("The Actual Path of the virtual directory : "+
MapPathSecure(TemplateSourceDirectory)+"<br>");
// Get all the files from the absolute path of 'MyControl';
// using TemplateSourceDirectory which gives the virtual Directory.
string [] myFiles=
Directory.GetFiles(MapPathSecure(TemplateSourceDirectory));
output.Write("The files in this Directory are <br>");
// List all the files.
for (int i=0;i<myFiles.Length;i++)
output.Write(myFiles[i]+"<br>");
' An HttpException occurs if the server control does not,;
' have permissions to read the resulting mapped file.
output.Write("The Actual Path of the virtual directory : " & _
MapPathSecure(TemplateSourceDirectory) & "<br>")
' Get all the files from the absolute path of 'MyControl';
' using TemplateSourceDirectory which gives the virtual Directory.
Dim myFiles As String() = Directory.GetFiles(MapPathSecure(TemplateSourceDirectory))
output.Write("The files in this Directory are <br>")
' List all the files.
Dim i As Integer
For i = 0 To myFiles.Length - 1
output.Write(myFiles(i) & "<br>")
Next i
Poznámky
Vlastnost TemplateSourceDirectory určuje cestu ke stránce nebo uživatelskému ovládacímu prvku, který obsahuje aktuální ovládací prvek. Pokud se například webová stránka nachází na http://www.contoso.com/application/subdirectoryadrese , TemplateSourceDirectory vrátí vlastnost "application/podadresář".
Pokud chcete vrátit virtuální cestu relativní vzhledem k aplikaci ("~/podadresář"), použijte AppRelativeTemplateSourceDirectory tuto vlastnost.