. Net generates the detail page and list as static pages 12010-01-27
Using system;
Using system. Collections. Generic;
Using system. text;
Using system. IO; // namespace of streamreader
Using system. Data;
Using *** _ logic; // The internal project space to hide it
Namespace DB
{
Public class createdb
{
/// <Summary>
//// // Generate a detailed page
/// </Summary>
/// <Param name = "strmfile"> template file name </param>
/// <Param name = "Strid"> News id </param>
/// <Param name = "strtilte"> News Title </param>
/// <Param name = "strcontents"> news content </param>
/// <Returns> </returns>
Public bool makehtmlfile (string strmfile, string Strid, string strtilte, string strcontents)
{
// Create HTML Encoding
Encoding ED = encoding. getencoding ("gb2312 ");
// Obtain the address for storing the template-relative path
String strpath = system. Web. httpcontext. Current. server. mappath ("../html /");
// Read the Template File
String strtemp = system. Web. httpcontext. Current. server. mappath ("../module/" + strmfile );
// Read the object
Streamreader sr = NULL;
// Write object
Streamwriter Sw = NULL;
String STR = "";
// Read the Template File
Sr = new streamreader (strtemp, Ed );
// Read the last row and assign it to Str
STR = Sr. readtoend ();
// Automatically generate the HTML file name
// String htmlfilename = strpath + datetime. Now. tostring ("yyyymmddhhmmss") + ". html ";
String htmlfilename = strpath + Strid + ". html ";
// Replace the value in the template with the value obtained from the text box.
STR = Str. Replace ("newstitle", strtilte );
STR = Str. Replace ("newsbody", strcontents );
// Start writing the created HTML file
Sw = new streamwriter (htmlfilename, false, Ed );
Sw. Write (STR );
Sw. Flush ();
Sw. Close ();
Return true;
}