C#生成HTML页类
来源:互联网 发布:电脑离线翻译软件 编辑:程序博客网 时间:2024/05/23 00:06
/// <summary>
/// 生成HTML页类
/// </summary>
public class ProduceHtmlPage
{
public static bool WriteFile(string strTopic,string strArticleClass,string strArticleClassChild,string strContent,string strSource,string strAuthor,string strEditor,string strPubDate,string strPageUrl)
{
string path = HttpContext.Current.Server.MapPath("/bluedn/html/");
Encoding code = Encoding.GetEncoding("gb2312");
//读取模板文件
string temp = HttpContext.Current.Server.MapPath("/bluedn/template/NewsInfo.htm");
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= strPageUrl+".htm";
//DateTime.Now.ToString("yyyyMMddHHmmss")+".htm";
//替换内容
//这时,模板文件已经读入到名称为str的变量中了
//模板页中的新闻标题
str = str.Replace("$t_Topic$",strTopic);
//一级栏目
str = str.Replace("$t_ArticleClass$",strArticleClass);
//二级栏目
str = str.Replace("$t_ArticleClassChild$",strArticleClassChild);
//新闻来源
str = str.Replace("$t_Source$",strSource);
//作者
str = str.Replace("$t_Author$",strAuthor);
//编辑
str = str.Replace("$t_Editor$",strEditor);
//发布日期
str = str.Replace("$t_PubDate$",strPubDate);
//新闻内容
str = str.Replace("$t_Content$",strContent);
//写文件
try
{
sw = new StreamWriter(path + htmlfilename , false, code);
sw.Write(str);
sw.Flush();
}
catch(Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
HttpContext.Current.Response.End();
}
finally
{
sw.Close();
}
return true;
}
}
/// 生成HTML页类
/// </summary>
public class ProduceHtmlPage
{
public static bool WriteFile(string strTopic,string strArticleClass,string strArticleClassChild,string strContent,string strSource,string strAuthor,string strEditor,string strPubDate,string strPageUrl)
{
string path = HttpContext.Current.Server.MapPath("/bluedn/html/");
Encoding code = Encoding.GetEncoding("gb2312");
//读取模板文件
string temp = HttpContext.Current.Server.MapPath("/bluedn/template/NewsInfo.htm");
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= strPageUrl+".htm";
//DateTime.Now.ToString("yyyyMMddHHmmss")+".htm";
//替换内容
//这时,模板文件已经读入到名称为str的变量中了
//模板页中的新闻标题
str = str.Replace("$t_Topic$",strTopic);
//一级栏目
str = str.Replace("$t_ArticleClass$",strArticleClass);
//二级栏目
str = str.Replace("$t_ArticleClassChild$",strArticleClassChild);
//新闻来源
str = str.Replace("$t_Source$",strSource);
//作者
str = str.Replace("$t_Author$",strAuthor);
//编辑
str = str.Replace("$t_Editor$",strEditor);
//发布日期
str = str.Replace("$t_PubDate$",strPubDate);
//新闻内容
str = str.Replace("$t_Content$",strContent);
//写文件
try
{
sw = new StreamWriter(path + htmlfilename , false, code);
sw.Write(str);
sw.Flush();
}
catch(Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
HttpContext.Current.Response.End();
}
finally
{
sw.Close();
}
return true;
}
}
- C#生成HTML页类
- C#生成HTML页类
- C#动态生成html
- c# 生成html
- C# HTML生成PDF
- C#生成HTML控件 代码
- C#动态生成html页面
- C#编写 HTML生成PDF
- C# 生成html文件-入门
- C#根据html生成PDF
- C# +HTML 生成验证码
- C#注释文档生成的HTML问题解决
- C#实现自动图片切分,生成HTML
- C#根据模板动态生成html页面
- C#之动态生成html文件
- C# system.web.ui生成html
- C#版生成HTML分页标签
- 根据html页面模板动态生成html页面(c#类)
- java编码
- IT幽默(超搞笑)
- 二叉树的遍历,二叉树的创建、前序遍历、中序遍历、后序遍历 (转)
- 三句话是如何暴露自己不职业的
- 电子式电能表试行检定规程
- C#生成HTML页类
- 交换网络中的嗅探和ARP欺骗(附代码)
- 我为什么畏首畏尾
- 小胖妞系列文章之二:不妨和工作谈一场恋爱
- 最完整的Windows启动与关机过程
- 装系统的磨难
- Jsp 验证码(检验码)的实现
- C#开发和使用中的几个实现方法
- 成年人必看的五个故事