dotnetzip

Compress file with dotnetzip, and when open it is corrupted

风流意气都作罢 提交于 2019-12-01 19:46:29
I create a zip file in a controller from a byte array and I return the zip file as a fileresult. When I download the zip File and extract the file, it is corrupt. I'm doing it this way: byte[] fileBytes =array MemoryStream fileStream = new MemoryStream(fileBytes); MemoryStream outputStream = new MemoryStream(); fileStream.Seek(0, SeekOrigin.Begin); using (ZipFile zipFile = new ZipFile()) { zipFile.AddEntry(returnFileName, fileStream); zipFile.Save(outputStream); } outputStream.Position = 0; FileStreamResult fileResult = new FileStreamResult(outputStream, System.Net.Mime.MediaTypeNames

ASP MVC Download Zip Files

扶醉桌前 提交于 2019-12-01 12:20:03
i have a view where i put the id of the event then i can download all the images for that event..... here's my code [HttpPost] public ActionResult Index(FormCollection All) { try { var context = new MyEntities(); var Im = (from p in context.Event_Photos where p.Event_Id == 1332 select p.Event_Photo); Response.Clear(); var downloadFileName = string.Format("YourDownload-{0}.zip", DateTime.Now.ToString("yyyy-MM-dd-HH_mm_ss")); Response.ContentType = "application/zip"; Response.AddHeader("content-disposition", "filename=" + downloadFileName); using (ZipFile zipFile = new ZipFile()) { zipFile

ASP MVC Download Zip Files

人走茶凉 提交于 2019-12-01 12:00:16
问题 i have a view where i put the id of the event then i can download all the images for that event..... here's my code [HttpPost] public ActionResult Index(FormCollection All) { try { var context = new MyEntities(); var Im = (from p in context.Event_Photos where p.Event_Id == 1332 select p.Event_Photo); Response.Clear(); var downloadFileName = string.Format("YourDownload-{0}.zip", DateTime.Now.ToString("yyyy-MM-dd-HH_mm_ss")); Response.ContentType = "application/zip"; Response.AddHeader("content

Can an encrypted zip-file also protect it's internal directory

社会主义新天地 提交于 2019-12-01 11:17:33
I'm creating an encrypted zip file using DotNetZip using WinZip AES 256. However I'm able to read the directory and even to remove some of the zipentries without having the encryption key. As far as I understand the directory visibility is a limitation of the Zip format. I just wonder, if this also applies for any changes in removing / adding components to the zip file or does there exist a way for preventing such changes. EDIT: A quick read of Zip File Format seems to show, that double zipping seems to be the only solution to prevent random removal / addition of comoponents in a zipfile,

Can an encrypted zip-file also protect it's internal directory

有些话、适合烂在心里 提交于 2019-12-01 08:40:21
问题 I'm creating an encrypted zip file using DotNetZip using WinZip AES 256. However I'm able to read the directory and even to remove some of the zipentries without having the encryption key. As far as I understand the directory visibility is a limitation of the Zip format. I just wonder, if this also applies for any changes in removing / adding components to the zip file or does there exist a way for preventing such changes. EDIT: A quick read of Zip File Format seems to show, that double

How to find uncompressed size of ionic zip file

試著忘記壹切 提交于 2019-12-01 08:36:26
I have a zip file compressed using Ionic zip . Before extracting I need to verify the available disk space. But how do I find the uncompressed size before hand? Is there any header information in the zip file (by ionic) so that I can read it? Taniq This should do the trick: static long totaluncompressedsize; static string info; . . . . // Option 1 foreach (ZipEntry e in zip) { long uncompressedsize = e.UncompressedSize; totaluncompressedsize += uncompressedsize; } // Or // Option 2 - will need to sift through the mass of info using (ZipFile zip = ZipFile.Read(zipFile)) { info = zip.Info; }

How to check whether file exists in zip file using dotnetzip

不羁的心 提交于 2019-12-01 06:06:05
I am creating zip using dotnetzip library. But I don't know how to check if a file exists in the zip. If the file exists then I will update the file with path. public void makezip(string flname) { string fln =flname; string curFile = @"d:\crs.zip"; if (File.Exists(curFile)) { ZipFile zipfl = ZipFile.Read(@"D:\crs.zip"); var result = zipfl.Any(entry => entry.FileName.EndsWith(@fln)); if (result == true) { zipfl.UpdateFile(@fln); }else{ zipfl.AddFile(@fln); } zipfl.Save(@"d:\crs.zip"); } else { try { ZipFile zipfl = new ZipFile(); var result = zipfl.Any(entry => entry.FileName.EndsWith(@fln));

Getting a “Cannot Read That as a Zip File” Exception while trying to get a stream from an Inner Zip File (a Zip within another Zip)

放肆的年华 提交于 2019-12-01 05:20:55
In C#, I'm using the DotNetZip I have a zip called "innerZip.zip" which contains some data, and another zip called "outerZip.zip" which contains the innerZip. why am i doing it like this ? well, when setting the password, the password actually applies to individual entries that are added to the archive and not the whole archive, by using this inner/outer combo, I could set a pass to the whole inner zip because it's an entry of the outer one. Problem is, well, code speaks better than normal words: ZipFile outerZip = ZipFile.Read("outerZip.zip"); outerZip.Password = "VeXe"; Stream innerStream =

Is there a way to decompress a DynaZip Max file with another library? F.E. DotNetZip

假如想象 提交于 2019-12-01 04:42:26
I have a database in which we stored pdf files compressed with DynaZip Max Secure, using the following code: MemoryStream msIN = new System.IO.MemoryStream(); //Input MemoryStream MemoryStream msZip = new System.IO.MemoryStream(); //Compressed MemoryStream BinaryReader objBinaryReader; BinaryWriter objBinaryWriter; public MemoryStream CompressStream(byte[] vbuf) { System.IO.BinaryWriter bw = new System.IO.BinaryWriter(msIN); bw.Write(vbuf); CDZipSNET dz1 = new CDZipSNET(); dz1.ZipMemToMemCallback += new CDZipSNET.OnZipMemToMemCallback(this.ZipMemToMemCallback_event); dz1.ActionDZ = CDZipSNET

How to handle unzipping ZipFile with paths that are too long/duplicate

删除回忆录丶 提交于 2019-12-01 03:19:09
When unzipping files in Windows, I'll occasionally have problems with paths that are too long for Windows (but okay in the original OS that created the file). that are "duplicate" due to case-insensitivity Using DotNetZip, the ZipFile.Read(path) call will crap out whenever reading zip files with one of these problems. Which means I can't even try filtering it out. using (ZipFile zip = ZipFile.Read(path)) { ... } What is the best way to handle reading those sort of files? Updated: Example zip from here: https://github.com/MonoReports/MonoReports/zipball/master Duplicates: https://github.com