public void WriteFile()
{
//---------------------读html模板页面到stringbuilder对象里----

StringBuilder htmltext = new StringBuilder();
try
{
string tempath = System.Configuration.ConfigurationManager.AppSettings["HotelReservationTemplate"];

using (StreamReader sr = new StreamReader(Server.MapPath( tempath))) //模板页路径
{
//String line;
//while ((line = sr.ReadLine()) != null)
//{
// htmltext.Append(line);
//}
//sr.Close();

string line = sr.ReadLine();
while (line != null)
{
htmltext.Append(line);
}
sr.Close();
}
}
catch
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "d3", "alert('读取文件错误!!')", true);
}

//---------------------给标记数组赋值------------

//----------替换htm里的标记为你想加的内容
for (int i = 0; i < 13; i++)
{
htmltext.Replace("$htmlformat[" + i + "]", m_format[i]);
}
m_HtmlText = htmltext.ToString();
//----------生成htm文件------------------――
try
{
string tempath = System.Configuration.ConfigurationManager.AppSettings["HotelReservation"];
string filename = DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".html";
string newPath = Server.MapPath(tempath) + filename;
//m_NewPath = newPath;
//using (StreamWriter sw = new StreamWriter(newPath, false, System.Text.Encoding.GetEncoding("GB2312"))) //保存地址
//{
// sw.WriteLine(htmltext);
// sw.Flush();
// sw.Close();
//}
}
catch
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "d4", "alert('发送失败!!')", true);
}
}