using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.IO;
/// <summary>
///ConvertHtmlPage 生成静态页面
/// </summary>
public class ConvertHtmlPage
{
/// <summary>
/// 生成HTML文件
/// </summary>
/// <param name="templatePath">模板路径</param>
/// <param name="templateName">模板名称</param>
/// <param name="htmlPath">生成HTML的路径</param>
/// <param name="htmlName">生成HTML的名称</param>
/// <param name="format">替换的内容</param>
/// <returns></returns>
public static bool CreatePage(string templatePath,string templateName, string htmlPath, string htmlName,List<string> format)
{
try
{
//读取模板文件
StringBuilder htmltext = new StringBuilder();
using (StreamReader sr = new StreamReader(templatePath+templateName))
{
string line;
while ((line = sr.ReadLine()) != null)
{
htmltext.AppendLine(line);
}
sr.Close();
}
//替换HTML中的标记内容
for (int i = 0; i < format.Count; i++)
{
htmltext.Replace("$htmlformat[" + i + "]", format[i]);
}
//生成HTML文件
using (StreamWriter sw = new StreamWriter(htmlPath+htmlName, false, System.Text.Encoding.GetEncoding("GB2312")))
{
sw.WriteLine(htmltext);
sw.Flush();
sw.Close();
}
}
catch (Exception ex)
{
return false;
}
return true;
}
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有