dotnetzip

DotNetZip: Add Files to Dynamically Created Archive Directory

江枫思渺然 提交于 2019-12-07 10:46:04
问题 I can't imagine this is hard to do, but I haven't been able to get it to work. I have a files class that just stores the location, directory, and name of the files I want to zip. The files I'm zipping exist on disk so the FileLocation is the full path. ZipFileDirectory doesn't exist on disk. If I have two items in my files list, { FileLocation = "path/file1.doc", ZipFileDirectory = @"\", FileName = "CustomName1.doc" }, { FileLocation = "path/file2.doc", ZipFileDirectory = @"\NewDirectory",

Sending Zip file to Client via Response with DotNetZip

…衆ロ難τιáo~ 提交于 2019-12-05 19:07:44
this is my code private void sendToClient(Dictionary<string, string> reportDic) { Response.Clear(); Response.BufferOutput = false; String ReadmeText = "some text"; Response.ContentType = "application/zip"; Response.AddHeader("content-disposition", "filename=" + "filename.zip"); using (ZipFile zip = new ZipFile()) { zip.AddEntry("Readme.txt", ReadmeText); zip.Save(Response.OutputStream); } Response.Close(); } at this point I'm simply trying to return a zip file with the readme.txt document inside the zip with the words "some text" inside the document. What I get is a zipfile named filename.zip

Extracting zip file in memory failing with C# DotNetZip

别来无恙 提交于 2019-12-05 18:04:43
I'm trying to download and extract a zip file in C#, specifically DotNetZip. When I run this code... HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(reportUrl); HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse(); Stream stream = response.GetResponseStream(); MemoryStream ms = new MemoryStream(); stream.CopyTo(ms); ms.Seek(0, 0); ZipInputStream zip = new ZipInputStream(ms); zip.Seek(0, 0); ZipEntry e = zip.GetNextEntry(); string s = e.FileName; MemoryStream ms2 = new MemoryStream(); e.Extract(ms2); After the Extract method executes, I get... $exception {"Object

DotNetZip: Add Files to Dynamically Created Archive Directory

隐身守侯 提交于 2019-12-05 12:04:14
I can't imagine this is hard to do, but I haven't been able to get it to work. I have a files class that just stores the location, directory, and name of the files I want to zip. The files I'm zipping exist on disk so the FileLocation is the full path. ZipFileDirectory doesn't exist on disk. If I have two items in my files list, { FileLocation = "path/file1.doc", ZipFileDirectory = @"\", FileName = "CustomName1.doc" }, { FileLocation = "path/file2.doc", ZipFileDirectory = @"\NewDirectory", FileName = "CustomName2.doc" } I would expect to see MyCustomName1.doc in the root, and a folder named

Compression fails when using ionic zip

寵の児 提交于 2019-12-04 04:45:00
I am using the latest version of ionic zip version 1.9.1.8.I have set the property of ionic zip ParallelDeflateThreshold = 0 . The zipping mechanism was working perfectly for the past two months.Suddenly this stopped working.The zipping thread just hangs,ionic zip just created the tmp file and failed to create the zip file. I could easily reproduce this issue even with small file size. My analysis for this issue is as follows The issue was with the latest version of ionic zip, in this case the ionic zip hanged while creating the zip files. We noticed that, a couple of other users who uses this

How to find uncompressed size of ionic zip file

喜夏-厌秋 提交于 2019-12-04 01:46:51
问题 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? 回答1: 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

Create and stream image archive zip file for download C#

给你一囗甜甜゛ 提交于 2019-12-03 20:58:52
I am using the beloved DotNetZip archiving library in MVC3 to generate a Zip file on the fly which contains .png images from binaries stored in a database. I then stream the generated Zip file out for the user to download. (I validate image data prior to saving to to the database, so you can assume that all image data is valid). public ActionResult PictureExport() { IEnumerable<UserPicture> userPictures = db.UserPicture.ToList(); //"db" is a DataContext and UserPicture is the model used for uploaded pictures. DateTime today = DateTime.Now; string fileName = "attachment;filename

Ionic Zip : Zip file creation from byte[]

馋奶兔 提交于 2019-12-03 14:06:46
Ionic zip allows me to add existing file to zip object and create a zip file. But considering that I am reading those byte[] from created zip file and sending over server, I need to again create zip file from that byte[] to store zip on server. How do I achieve this ? I am using C#. If I understand your question correctly, you get your byte[] data array over the network and want to save that data in a zip file? You can create a new ZipEntry from a MemoryStream which you create from the byte[] you got (as shown in the docs ): byte[] data = MethodThatReceivesYourDataOverTheNet(); using

DotNetZip: How to extract files, but ignoring the path in the zipfile?

假如想象 提交于 2019-12-03 11:39:04
Trying to extract files to a given folder ignoring the path in the zipfile but there doesn't seem to be a way. This seems a fairly basic requirement given all the other good stuff implemented in there. What am i missing ? code is - using (Ionic.Zip.ZipFile zf = Ionic.Zip.ZipFile.Read(zipPath)) { zf.ExtractAll(appPath); } Software.Developer You'll need to remove the directory part of the filename just prior to unzipping... using (var zf = Ionic.Zip.ZipFile.Read(zipPath)) { zf.ToList().ForEach(entry => { entry.FileName = System.IO.Path.GetFileName(entry.FileName); entry.Extract(appPath); }); }

Zipping a file using DotNetZip on C# on mac

浪子不回头ぞ 提交于 2019-12-02 18:22:37
问题 I am trying to zip a file or directory in C# using the following snippet of code on a mac that uses DotNetZip. But I get some exceptions below, what am I doing wrong? using Ionic.Zip; namespace CSLab { class Program { static void Main(string[] args) { using (ZipFile zip = new ZipFile()) { zip.Password = "password"; zip.AddDirectory("./test"); zip.Save("a.zip"); } } } } Unhandled Exception: System.ArgumentException: 'IBM437' is not a supported encoding name. For information on defining a