html 模板替换

public void OffAddModel()
{
string title = Request["title"];//标题
string sendTime = Request["sendTime"];//发布时间
string originalUnit = Request["originalUnit"];//官方部门
string link = Request["link"];//超链接
string fujian = Request["fujian"];//附件
string fujianUrl = Request["fujianUrl"];//附件路径
string conter = Request["conter"];//内容

string path = Server.MapPath("OffAddModel.html");//取到模板的物理路径
StreamReader sr = new StreamReader(path, Encoding.UTF8);
string strModel = sr.ReadToEnd();
strModel = strModel.Replace("$title", title);
strModel = strModel.Replace("$sendTime", sendTime);
strModel = strModel.Replace("$originalUnit", originalUnit);
strModel = strModel.Replace("$conter", conter);
strModel = strModel.Replace("$link", link);
strModel = strModel.Replace("$fujian", fujian);
strModel = strModel.Replace("$fujianUrl", fujianUrl);

FileStream ff = new FileStream(path.Replace("OffAddModel", "aa"), FileMode.CreateNew);
byte[] buffer = Encoding.UTF8.GetBytes(strModel);
ff.Write(buffer, 0, buffer.Length);
ff.Close();
}

posted @ 2015-08-06 17:42  成小伟  阅读(496)  评论(0编辑  收藏  举报