Environment: Microsoft .NET Framework SDK V1.1 OS: Windows Server 2003 Chinese version ASP.NET Generates a FileSystemObject object that is implemented in a static HTML page in ASP! In .NET involves this type of operation, SYSTEM. IO is the program code note: This code is non-original! Refer to other person code // Generate HTML Pable Public Static Bool Writefile (String Strauth) {string path = httpcontext.current.server.mAppath ("/ news / "); Encoding code = encoding.getencoding (" GB2312 "); // Read Template file string temp = httpContext.current.server.mappath (" / news / text.html "); streamReader sr = null; streamwriter sw = NULL; STRING STR = ""; try {sr = new streamreader (TEMP, CODE); str = sr.readToEnd (); // Read file} catch (exception exp) {httpContext.current.response.write (EXP. Message); httpcontext.current.response.end (); sr.close ();} String htmlfilename = DATETIME.NOW.TOSTRING ("YYYYMMDDHHMMSS") ". Html"; // Replace content // Template file Str = str.replace ("ShowArticle", Strtext) in the name of STR; // ("Biaoti", Strtext); str = str.replace ("Biaoti", StRText); str = str.replace (Str.Rept); "content", strcontent; Str = str.replace ("author", strauthor); // write file try {sw = new streamwriter (Path HTMLFileName, False, Code); sw.flush ();} catch (Exception EX) {httpcontext.current.response.write; httpContext.current.response.end ();} finally {sw.close ();} return true; this function is placed in the conn.cs base class. Quote in the code of adding news Note: Engineering named HOVER IF (Hover.Conn.writeFileTHis.title.Text.TString), this.content.text.toString, this.Author.Text.Tostring))) {response. Write ("Add success");} else {response.write ("Generate HTML Error!");
} ------------------------------------- ------------------------ Template page text.html code -------------------- -------------------------------------------------- ---
Biaoti
Content
Author Body> HTML>
Biaoti
Content
Author Body> HTML>
-------------------------------------------------- ---------------------- prompt to add a successful HTML file with the current time as the file name! Only just written directly from several parameters passed In the HTML file, you need to add the database in practical applications, then write to the HTML file and you need to write the generated file name to the digital library for later calls, etc., this instance is only implemented in the template according to the submitted parameters The corresponding field! There are a lot of places that need to be perfect! Which is high, welcome to enlighten me!
Author Blog:
http://blog.9cbs.net/coofucoo/