码迷,mamicode.com
首页 > 其他好文 > 详细

生成静态页

时间:2015-01-07 00:29:48      阅读:258      评论:0      收藏:0      [点我收藏+]

标签:

namespace Web
{
public partial class StaticPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void btnOK_Click(object sender, EventArgs e)
{

try
{
//拿到文本框里面的数字
int start = int.Parse(txtStart.Text);
int end = int.Parse(txtEnd.Text);

string path = Request.MapPath("/");
string temp = File.ReadAllText(Request.MapPath("/BookInfoShow.html"));
BookInfoBLL bll = new BookInfoBLL();
for (int i = start; i <= end; i++)
{
string path2 = path + (i / 5000);
if (!Directory.Exists(path2))
{
Directory.CreateDirectory(path2);
}
//根据编号查对象
BookInfo bookInfo = bll.GetOneModel(i);
if (bookInfo == null)
{
return;
}
string path3 = Path.Combine(path2, bookInfo.id + ".html");
string temp2 = temp.Replace("", bookInfo.id.ToString()).Replace("", bookInfo.name.ToString());
File.WriteAllText(path3, temp2);
Label1.Text = "生成成功";
}
}
catch (Exception)
{

Label1.Text = "生成失败";
}

}
}
}

生成静态页

标签:

原文地址:http://www.cnblogs.com/bidianqing/p/4207336.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!