我爱Aspx >> Asp.Net >> C#静态页面生成
环境:Microsoft .NET Framework SDK v1.1
OS:Windows Server 2003 中文版
ASP.Net生成静态HTML页
在Asp中实现的生成静态页用到的FileSystemObject对象!
在.Net中涉及此类操作的是System.IO
以下是程序代码 注:此代码非原创!参考别人代码
//生成HTML页
public static bool WriteFile(string strText,string strContent,string strAuthor)
{
string path = HttpContext.Current.Server.MapPath("/news/");
Encoding code = Encoding.GetEncoding("gb2312");
// 读取模板文件
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(); // 读取文件
}
catch(Exception exp)
{
HttpContext.Current.Response.Write(exp.Message);
HttpContext.Current.Response.End();
sr.Close();
}
string htmlfilename=DateTime.Now.ToString("yyyyMMddHHmmss")+".html";
Ҷƪл˵?
如何开发一个多种语言版本的C#程..[04-21]
c#.net存储过程版本的分页[04-21]
学习C#静态函数及变量的一个精典..[04-21]
用C#绘柱形图(owc编程)[04-21]
解读C#中的规则表达式(正则表达..[04-21]
C#中的特性(Attributes)[04-21]
几个C#写的网络相关开源组件[04-21]
c#学习体会:使用 ref 和 out 传递..[04-21]
c#中使用ref和out一点认识[04-21]
C#的前途如何?[04-21]
如何开发一个多种语言版本的C#程..[04-21]
c#.net存储过程版本的分页[04-21]
学习C#静态函数及变量的一个精典..[04-21]
Calendar如何只显示“一、二、三..[04-21]
预防SQL注入攻击(译自MSDN)[04-21]
两种取得硬盘剩余空间方法[04-21]
用XenoCode 2006 加密dll (.NET混..[04-21]
用JSON技术加快AJAX程序开发[04-21]
用C#绘柱形图(owc编程)[04-21]
JS的IE和Firefox兼容性汇编[04-21]