您的位置:首页 > 其它

备份文件及恢复文件[WEB学习实例]

2008-10-18 10:40 302 查看
protected void Button11_Click(object sender, EventArgs e)//备份
{ Bei_Fen_data(); }

protected void Bei_Fen_data()//备份
{
string DateTimes = System.DateTime.Now.Year.ToString() + System.DateTime.Now.Month.ToString() + System.DateTime.Now.Day.ToString() + System.DateTime.Now.Hour.ToString() + System.DateTime.Now.Minute.ToString() + System.DateTime.Now.Second.ToString();
if (!File.Exists(Server.MapPath(@"~/DataBasc/" + "备份" + DateTimes + ".aspx")))
{
File.Copy(Server.MapPath(@"~/Data/So.aspx"), Server.MapPath(@"~/DataBasc/" + "备份" + DateTimes + ".aspx"));
System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "tixin", "alert('备份成功。')", true);
}
else { System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "tixin", "alert('备份失败?')", true); }
}

protected void Button12_Click(object sender, EventArgs e)//还原
{
File.Copy(Server.MapPath(@"~/DataBasc/" + DropDownList8.Text), Server.MapPath(@"~/Data/So.aspx"), true);
System.Web.UI.ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "tixin", "alert('恢复成功。')", true);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: