protected System.Web.UI.WebControls.TextBox txtFDate;
protected System.Web.UI.WebControls.TextBox txtTDate;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label lblFbjg;

private void Page_Load(object sender, System.EventArgs e)
{  if (!Page.IsPostBack)
{
txtFDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
txtTDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
 
}
}
private void Button1_Click(object sender, System.EventArgs e)
{
lblFbjg.Text = "";
    string sql = "select * from t_news where date between '"+txtFDate.Text +"' and '"+txtTDate.Text+"' order by id desc";
DataTable dt  = (new CommonData()).GetDataTable(sql);
System.Net.WebClient client = new System.Net.WebClient();
try
{
client.DownloadFile(UrlBase+"/index.aspx",Server.MapPath("../../index.htm"));
lblFbjg.Text +="发布首页成功!<br>";
}
catch
{
lblFbjg.Text +="发布首页成功失败,<font color='red'>请再试一下,如果还有问题,请与管理员联系!</font>" + "<br>";
}
foreach (DataRow dr in dt.Rows)
{
if (!Directory.Exists(Server.MapPath("../../news/"+DateTime.Parse(dr["date"].ToString()).ToString("yyyyMMdd"))))
Directory.CreateDirectory(Server.MapPath("../../news/"+DateTime.Parse(dr["date"].ToString()).ToString("yyyyMMdd")));
try
{
client.DownloadFile(UrlBase+"/enjoyauto/newsview.aspx?id="+dr["id"].ToString(),Server.MapPath("../../news/"+DateTime.Parse(dr["date"].ToString()).ToString("yyyyMMdd"))+"/"+dr["id"].ToString()+".htm");
lblFbjg.Text +="发布:"+dr["title"].ToString()+" 成功!<br>";
}
catch
{
lblFbjg.Text +="发布:" + dr["title"].ToString() + " 失败,<font color='red'>请再试一下,如果还有问题,请与管理员联系!</font>" + "<br>";
}
} }