代码如下:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Mysqlserver;//数据库操作类
using System.IO;
using System.Text;
namespace NewsAdd
{
public partial class Admin_AdminPanel_NewsAdd : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string strTitle=Request.Form["Title"].ToString();
string strContent=Request.Form["Content"].ToString();
SqlServerDataBase db = new SqlServerDataBase();
bool success = db.Insert("insert into inNews(Title,Content)values('" + strTitle + "','" + strContent + "')", null);
//if (success)
// Message.Text = "添加成功!";
/**////////////////////////////创建当前日期的文件夹开始
string dir = Server.MapPath("../../"+"NewsFiles/"+DateTime.Now.ToString("yyMMdd"));
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
/**////////////////////////////创建当前日期的文件夹结束
string[] newContent = new string[5];//定义和html标记数目一致的数组
StringBuilder strhtml = new StringBuilder();
try
{
//创建StreamReader对象
using (StreamReader sr = new StreamReader(Server.MapPath("../../" + "NewsFiles/") + "/template.html"))
新闻热点
疑难解答
图片精选