日期:2014-05-17 浏览次数:20409 次
protected void Button1_Click(object sender, EventArgs e)
{
StreamWriter sw = null;
StreamReader sr = null;
string htmlfilename = "";
string str1 = "";
string path1 = HttpContext.Current.Server.MapPath("i.htm");
string path = HttpContext.Current.Server.MapPath("~/");
try
{
sr = new StreamReader(path1, Encoding.GetEncoding("GB2312"));
str1 = sr.ReadToEnd();
}
catch (Exception ex)
{
throw ex;
}
finally
{
sr.Close();
}
try
{
for (int i = 0; i < 4; i++)
{
htmlfilename = "ceshi_" + i + ".html";
sw = new StreamWriter(path + htmlfilename, false, Encoding.GetEncoding("GB2312"));
str1 = str1.Replace("$i$", i.ToString());
sw.Write(str1);
sw.Flush();
}
}
catch (Exception ex)
{
HttpContext.Current.Response.Write(ex);
HttpContext.Current.Response.End();
}
finally
{
sw.Close();
}
}
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<