不知道博客园有多少朋友在使用AspSpider提供的免费空间,这里想给大家提个醒,AspSpider 将在2008年6月1日删除所有空间,需要备份的朋友请赶紧把自己的空间备份转移,以免造成不必要的损失。
似乎这个空间已经不提供备份功能了(更正,找到不能备份的原因了,空间使用较多,如果加上备份文件要超过10M,所以就不给备份了),我尝试了多次都没有成功。如果你也需要备份自己的目录,可以尝试下面这段代码:
这段代码引用了 SharpZipLib。
如果你是个懒人,你也可以直接下载这个压缩包上传到你的服务器。
https://files.cnblogs.com/hardrock/packfolder.zip
下面就是我今天登陆后看到的页面提示信息。
It is with deep regret that we inform you that starting May 1, 2008, AspSpider.net will stop offering its free ASP.NET web hosting services. After May 1, 2008, your web sites will remain online for 30 days so that you have the opportunity to download your web site files and seek alternative hosting options. On June 1, 2008, all of our servers will be wiped clean and all web site files will be removed.
似乎这个空间已经不提供备份功能了(更正,找到不能备份的原因了,空间使用较多,如果加上备份文件要超过10M,所以就不给备份了),我尝试了多次都没有成功。如果你也需要备份自己的目录,可以尝试下面这段代码:
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 ICSharpCode.SharpZipLib.Zip;
using System.IO;
public partial class packfolder : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MemoryStream ms = new MemoryStream();
byte[] buffer;
string path = MapPath("");
string[] files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
using (ZipOutputStream s = new ZipOutputStream(ms))
{
s.SetLevel(9); // 0-9, 9 being the highest compression
foreach (string file in files)
{
ZipEntry entry = new ZipEntry(file.Substring(path.Length+1));
entry.DateTime = DateTime.Now;
s.PutNextEntry(entry);
buffer=File.ReadAllBytes(file);
s.Write(buffer, 0, buffer.Length);
}
s.Finish();
s.Close();
}
buffer = ms.ToArray();
Response.ContentType = "application/zip";
Response.AddHeader("Content-disposition", "attachment; filename= *.zip");
Response.OutputStream.Write(buffer, 0, buffer.Length);
Response.End();
}
}
这段代码功能很简单,把制定目录和子目录中的文件按照目录结构压缩到zip文件中供下载,这里我是为了方便,直接默认当前文件所在目录了,这样就可以方便下载整个webroot目录了。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 ICSharpCode.SharpZipLib.Zip;
using System.IO;
public partial class packfolder : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
MemoryStream ms = new MemoryStream();
byte[] buffer;
string path = MapPath("");
string[] files = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
using (ZipOutputStream s = new ZipOutputStream(ms))
{
s.SetLevel(9); // 0-9, 9 being the highest compression
foreach (string file in files)
{
ZipEntry entry = new ZipEntry(file.Substring(path.Length+1));
entry.DateTime = DateTime.Now;
s.PutNextEntry(entry);
buffer=File.ReadAllBytes(file);
s.Write(buffer, 0, buffer.Length);
}
s.Finish();
s.Close();
}
buffer = ms.ToArray();
Response.ContentType = "application/zip";
Response.AddHeader("Content-disposition", "attachment; filename= *.zip");
Response.OutputStream.Write(buffer, 0, buffer.Length);
Response.End();
}
}
这段代码引用了 SharpZipLib。
如果你是个懒人,你也可以直接下载这个压缩包上传到你的服务器。
https://files.cnblogs.com/hardrock/packfolder.zip
下面就是我今天登陆后看到的页面提示信息。
AspSpider Free Hosting Termination Notice
It is with deep regret that we inform you that starting May 1, 2008, AspSpider.net will stop offering its free ASP.NET web hosting services. After May 1, 2008, your web sites will remain online for 30 days so that you have the opportunity to download your web site files and seek alternative hosting options. On June 1, 2008, all of our servers will be wiped clean and all web site files will be removed.