C# ASP.NET 3.5: zip more than 65535 dynamic files with SharpZipLib -
i'm trying zip 100 000 dynamic files, , on console app can without problem, on web app appears it's @ kind impossible.
console
static void main(string[] args) { using (zipoutputstream zipoutputstream = new zipoutputstream(file.create("test.zip"))) { zipoutputstream.setlevel(0); (long = 1; < 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
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); (long = 1; < 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(); }
so far know there should zip file amount limit 65535 files on console not matter. know can use zipoutputstream.usezip64 = usezip64.on not change anything. there way solve issue ?
edit: forgot mention file created on unzipping it's broken
Comments
Post a Comment