Name of the file to be read (with judgment conditions)

Source: Internet
Author: User

///   <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 );
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.