using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string strDate = DateTime.Now.ToString("yyMMdd");
string strTitle=this.Title.Text;//接收传过来的标题
string strContent=this.TextBox1.Text;//接收传过来的内容
string[] content = strContent.Split(new Char[] {'|'});//对内容进行拆分,并保存到数组
int upbound = content.Length;//数组的上限
/**/
///////////////////////////创建当前日期的文件夹开始
string strDir="NewsFiles/"+DateTime.Now.ToString("yyyy-MM-dd")+"/";
string dir = Server.MapPath(strDir);//用来生成文件夹
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
/**/
///////////////////////////创建当前日期的文件夹结束
/**////////////////////////////创建当前日期的文件夹结束
try
{
for (int i = 0; i < content.Length; i++)
{
StringBuilder strhtml = new StringBuilder();
//创建StreamReader对象
using (StreamReader sr = new StreamReader(Server.MapPath("template.html"), Encoding.GetEncoding("gb2312")))
{
String oneline;
//读取指定的HTML文件模板
while ((oneline = sr.ReadLine()) != null)
{
strhtml.Append(oneline);
}
sr.Close();
}
//上下页表格,注意此处的upUrl(上一页),Number(页码分页),downUrl(下一页)
string strTable = "<table><tr><td>upUrl</td><td>Number</td><td>downUrl</td></tr></table>";
string FilePath = "";
strhtml = strhtml.Replace("Title", "ddddddddddd");
strhtml = strhtml.Replace("NewsId", "10000");
strhtml = strhtml.Replace("Time", DateTime.Now.ToString("yyyy/MM/dd"));
strhtml = strhtml.Replace("Content", content[i]);
string strNumber = "";//数字分页1,2,3……
for (int m = 1; m <= upbound; m++)
{
if (m == 1)//如果是第一页就显示成这个样子:20070524.html而不是20070524_1.html
strNumber = strNumber + " [" + "<a href=" + strDate + ".html" + ">" + m + "</a>" + "] ";
else
{
int n = m - 1;//第三页的连接应该是20070524_2.html,以此类推
strNumber = strNumber + " [" + "<a href=" + strDate + "_" + n + ".html" + ">" + m + "</a>" + "] ";
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string strDate = DateTime.Now.ToString("yyMMdd");
string strTitle=this.Title.Text;//接收传过来的标题
string strContent=this.TextBox1.Text;//接收传过来的内容
string[] content = strContent.Split(new Char[] {'|'});//对内容进行拆分,并保存到数组
int upbound = content.Length;//数组的上限
/**/
///////////////////////////创建当前日期的文件夹开始
string strDir="NewsFiles/"+DateTime.Now.ToString("yyyy-MM-dd")+"/";
string dir = Server.MapPath(strDir);//用来生成文件夹
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
/**/
///////////////////////////创建当前日期的文件夹结束
/**////////////////////////////创建当前日期的文件夹结束
try
{
for (int i = 0; i < content.Length; i++)
{
StringBuilder strhtml = new StringBuilder();
//创建StreamReader对象
using (StreamReader sr = new StreamReader(Server.MapPath("template.html"), Encoding.GetEncoding("gb2312")))
{
String oneline;
//读取指定的HTML文件模板
while ((oneline = sr.ReadLine()) != null)
{
strhtml.Append(oneline);
}
sr.Close();
}
//上下页表格,注意此处的upUrl(上一页),Number(页码分页),downUrl(下一页)
string strTable = "<table><tr><td>upUrl</td><td>Number</td><td>downUrl</td></tr></table>";
string FilePath = "";
strhtml = strhtml.Replace("Title", "ddddddddddd");
strhtml = strhtml.Replace("NewsId", "10000");
strhtml = strhtml.Replace("Time", DateTime.Now.ToString("yyyy/MM/dd"));
strhtml = strhtml.Replace("Content", content[i]);
string strNumber = "";//数字分页1,2,3……
for (int m = 1; m <= upbound; m++)
{
if (m == 1)//如果是第一页就显示成这个样子:20070524.html而不是20070524_1.html
strNumber = strNumber + " [" + "<a href=" + strDate + ".html" + ">" + m + "</a>" + "] ";
else
{
int n = m - 1;//第三页的连接应该是20070524_2.html,以此类推
strNumber = strNumber + " [" + "<a href=" + strDate + "_" + n + ".html" + ">" + m + "</a>" + "] ";