甚至可以使用sharpziplib压缩超过65535个动态文件? [英] Is it even possible to zip more than 65535 dynamic files with sharpziplib ?
本文介绍了甚至可以使用sharpziplib压缩超过65535个动态文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试压缩100 000个动态文件,并且在控制台应用程序上我可以毫无问题地执行此操作,但在Web应用程序中,它似乎在我目前的知识水平上是某种形式。我想知道这真的不可能吗?
到目前为止在webapp上制作的zip文件大于65535个文件在打开时崩溃。
我尝试了什么:
我做了这个测试应用程序,但我找不到答案。
console
I'm trying zip 100 000 dynamic files, and on console app i can do it without any problem, but on web app it appears that it's at some kind impossible for my current knowledge level. I would like to know is it really impossible ?
So far zip made on webapp that is bigger than 65535 files crashes on opening.
What I have tried:
I made this test apps but I wasn't able to find answer.
console
static void Main(string[] args)
{
using (ZipOutputStream zipOutputStream = new ZipOutputStream(File.Create("Test.zip")))
{
zipOutputStream.SetLevel(0);
for (long i = 1; i < 100000; i++)
{
string txt = "File " + i.ToString();
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(txt);
using (MemoryStream ms = new MemoryStream(bytes))
{
ZipEntry entry =
new ZipEntry(ZipEntry.CleanName(i.ToString() + ".txt"))
{
DateTime = DateTime.Now,
CompressionMethod = CompressionMethod.Stored,
Size = bytes.Length
};
zipOutputStream.PutNextEntry(entry);
byte[] buffer = new byte[1024];
ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(ms, zipOutputStream, buffer);
Console.WriteLine(i.ToString());
}
}
}
}
web
web
protected void Page_Load(object sender, EventArgs e)
{
Response.Clear();
Response.ClearHeaders();
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + "file.zip");
using (ZipOutputStream zipOutputStream = new ZipOutputStream(Response.OutputStream))
{
zipOutputStream.SetLevel(0);
for (long i = 1; i < 100000; i++)
{
string txt = "File " + i.ToString();
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(txt);
using (MemoryStream ms = new MemoryStream(bytes))
{
ZipEntry entry =
new ZipEntry(ZipEntry.CleanName(i.ToString() + ".txt"))
{
DateTime = DateTime.Now,
CompressionMethod = CompressionMethod.Stored,
Size = bytes.Length
};
zipOutputStream.PutNextEntry(entry);
byte[] buffer = new byte[1024];
ICSharpCode.SharpZipLib.Core.StreamUtils.Copy(ms, zipOutputStream, buffer);
Response.Flush();
}
}
}
Response.Flush();
Response.End();
}
推荐答案
不,这是不可能的。这花了我大约10秒钟到谷歌。
尝试使用DotNetZip。
No, it isn't possible. That took me about 10 seconds to Google for.
Try DotNetZip instead.
这篇关于甚至可以使用sharpziplib压缩超过65535个动态文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文