一键网站备份与asp.net [英] One-click web site backup with asp.net
本文介绍了一键网站备份与asp.net的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要备份我的网站经常但不是我的备份通过FTP程序文件,我想这会复制我的所有文件和压缩他们,让下载一个一键式解决方案。可以这样用asp.net在同一个网站上做了或我必须写一个.NET应用程序用于这个目的?
I want to backup my web site regularly but instead of backup my files via ftp program I want a one-click solution which will copy all my files and zip them and allow to download. Can this be done with asp.net at same web site or I have to write a .net app for this purpose?
推荐答案
备份是很容易使用 DotNetZip 。只要给一个目录名来备份,然后等待文件下载。甚至可以设置为压缩密码。我爱开源解决方案。
Backup was very easy with DotNetZip. Just give a directory name to backup and wait file to be downloaded. Even can set a password for the zip. I love open-source solutions.
using Ionic.Zip;
public void btnOneClickZip_Click(Object sender, EventArgs e)
{
Response.Clear();
Response.BufferOutput = false;
string archiveName = String.Format("backup-{0}.zip",
DateTime.Now.ToString("yyyy-MM-dd-HHmmss"));
Response.ContentType = "application/zip";
Response.AddHeader("content-disposition", "filename=" + archiveName);
using (ZipFile zip = new ZipFile())
{
zip.AddDirectory(Server.MapPath("~/Assets/Upload/"),
"httpdocs/Assets/Upload");
zip.AddDirectory(Server.MapPath("~/App_Data/"), "httpdocs/App_Data");
zip.Save(Response.OutputStream);
}
Response.Close();
}
这篇关于一键网站备份与asp.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文