I’m pretty sure this is not a duplicate so bear with me for just a minute.
How can I programatically (C#) ZIP a file (in Windows) without using any third party libraries? I need a native windows call or something like that; I really dislike the idea of starting a process, but I will if I absolutely have to. A PInovke call would be much better.
Failing that, let me tell you what I’m really trying to accomplish: I need the ability to let a user download a collection of documents in a single request. Any ideas on how to accomplish this?
Are you using .NET 3.5? You could use the
ZipPackageclass and related classes. Its more than just zipping up a file list because it wants a MIME type for each file you add. It might do what you want.I’m currently using these classes for a similar problem to archive several related files into a single file for download. We use a file extension to associate the download file with our desktop app. One small problem we ran into was that its not possible to just use a third-party tool like 7-zip to create the zip files because the client side code can’t open it — ZipPackage adds a hidden file describing the content type of each component file and cannot open a zip file if that content type file is missing.