日期:2009-08-16  浏览次数:20416 次

{

  HTMLtext.Replace("$HTMLformat["+i+"]",format[i]);

  }

  //----------生成htm文件------------------――

  try

  {

  using(StreamWriter sw=new StreamWriter("存放路径和页面名",false,System.Text.Encoding.GetEncoding("GB2312")))

  {

  sw.WriteLine(HTMLtext);

  sw.Flush();

  sw.Close();

  }

  }

  catch

  {

  Response.Write ("The file could not be wirte:");

  }

  小结

  用此方法可以方便的生成HTML文件。程序使用了是循环替换,因此对需替换大量元素的模板速度非常快。