/// <Summary>
/// Traverse the template file in the path and save it to hashtable.
/// </Summary>
/// <Param name = "directorypath"> Folder to be scanned </Param>
/// <Param name = "ht"> Returned template and configuration file </Param>
/// <Returns> Returns the hashtable containing the template file and configuration file. </Returns>
Private Hashtable gettemplatesfrompath ( String Directorypath)
{
Hashtable HT = New Hashtable ();
// Direct to template directory
Directoryinfo dirinfo = New Directoryinfo (getmappath ( " Templates/ " + Directorypath + " / " ));
// Traverse files in the template directory
Foreach (Filesysteminfo File In Dirinfo. getfilesysteminfos ())
{
// Remove the module containing files in the header from a page with a suffix of .htm and an ice-opening page with no line below)
If (File ! = Null && (File. extension. tolower (). Equals ( " . Html " ) | File. extension. tolower (). Equals ( " . Config " )) && File. Name. indexof ( " _ " ) ! = 0 )
{
HT = File;
}
}
Return HT;
}
/// <Summary>
/// Obtain the current absolute path
/// </Summary>
/// <Param name = "strpath"> Specified path </Param>
/// <Returns> Absolute path </Returns>
Public Static String Getmappath ( String Strpath)
{
If (Httpcontext. Current ! = Null )
{
Return Httpcontext. Current. server. mappath (strpath );
// Return strpath;
}
Else // Non-WebProgramReference
{
Strpath = Strpath. Replace ( " / " , " \\ " );
If (Strpath. startswith ( " \\ " ))
{
Strpath = Strpath. substring (strpath. indexof ( ' \\ ' , 1 ). Trimstart ( ' \\ ' );
}
Return System. Io. Path. Combine (appdomain. currentdomain. basedirectory, strpath );
}
}