到底这段代码有什么用啊怎么生成静态页没有效果啊!!!
using System.IO;
using System.Text;
public partial class jingtai : System.Web.UI.Page
{
public string temp = HttpContext.Current.Server.MapPath("write.htm");
public Encoding code = Encoding.GetEncoding("gb2312");
public StreamReader sr = null;
public string str = "";
public StreamWriter sw = null;
public string htmlfilename = DateTime.Now.ToString("yyyyMMddHHmmss") + ".html";//文件名
private void Page_Load(object sender, System.EventArgs e)
{
try
{
sr = new StreamReader(temp, code);
str = sr.ReadToEnd(); // 读取文件
}
catch (Exception exp)
{
HttpContext.Current.Response.Write(exp.Message);
HttpContext.Current.Response.End();
}
finally
{
sr.Close();
}
//-------------------------------------------------------------------
//-------------------------------------------------------------------
//-------------------------------------------------------------------
try
{
sw = new StreamWriter(Server.MapPath(htmlfilename), false, code);
str = str.Replace("aa", "chi");//文本替代
sw.Write(str);
sw.Flush();
}
catch (Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
HttpContext.Current.Response.End();
}
finally
{
sw.Close();
}
}
}
谢谢啊