如何实现多文件压缩
解决方案 »
- asp.net制作的网站,用手机访问时,如何做到想访问手机淘宝一样,左右划手机屏幕可切换图片!
- 浏览器兼容
- HttpContext.Current.Session与Page.Session的区别
- ASP.NET 未被授权访问所请求的资源。 请教!!
- 引用COM组件MSXML2出现异常:接口 MSXML2.IXMLHTTPRequest 的 QueryInterface 失败。
- 还是dataGrid中的问题,100
- 动态链接能否调用VB.net中的带参函数?急,在线等待
- 请教 数据库问题
- <<<急>>>调试时遇到身份验证错误!
- 在线用户问题(Session,Application)
- 2003 asp.net网站访问不了(急)
- 急!急!在哪能找到project Dependencies 选项卡,我怎么找不到啊?
{
string path = base.Server.MapPath(this.tbZipFolder.Text);
if (Directory.Exists(path))
{
if (!path.EndsWith(@"\"))
{
path = path + @"\";
}
try
{
string str2 = base.Server.MapPath(this.tbZipFolderTo.Text);
if (!Directory.Exists(Path.GetDirectoryName(str2)))
{
Directory.CreateDirectory(Path.GetDirectoryName(str2));
}
string[] strArray = Directory.GetFiles(path, "*.*", SearchOption.AllDirectories);
string[] strArray2 = Directory.GetDirectories(path, "*", SearchOption.AllDirectories);
using (ZipOutputStream stream = new ZipOutputStream(File.Create(str2)))
{
ZipEntry entry;
stream.SetLevel(9);
byte[] buffer = new byte[0x1000];
foreach (string str3 in strArray2)
{
entry = new ZipEntry(str3.Remove(0, path.Length) + @"\");
entry.set_DateTime(DateTime.Now);
stream.PutNextEntry(entry);
}
foreach (string str4 in strArray)
{
entry = new ZipEntry(str4.Remove(0, path.Length));
entry.set_DateTime(DateTime.Now);
stream.PutNextEntry(entry);
using (FileStream stream2 = File.OpenRead(str4))
{
int num;
do
{
num = stream2.Read(buffer, 0, buffer.Length);
stream.Write(buffer, 0, num);
}
while (num > 0);
}
}
stream.Finish();
stream.Close();
}
this.labelMsg.Text = string.Format("压缩目录[{0}]到文件[{1}]成功", this.tbZipFolder.Text, this.tbZipFolderTo.Text);
}
catch (Exception exception)
{
this.labelMsg.Text = exception.Message;
}
}
else
{
this.labelMsg.Text = string.Format("目录[{0}]不存在", this.tbZipFolder.Text);
}
}