I like to zip multiple files which are being created dynamically in my web application. Those files should be zipped. For this, i dont want to use any third-party tools. just like to use .net api in c#
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
- How to know full paths to DLL's from .csproj f
DotNetZip is the way to go (dotnetzip.codeplex.com)... don't try the .NET Packaging library.. too hard to use and the [Content_Types].xml that it puts in there bothers me..
With the release of the .NET Framework 4.5 this is actually a lot easier now with the updates to System.IO.Compression which adds the ZipFile class. There is a good walk-through on codeguru; however, the basics are in line with the following example:
I'm not sure what you mean by not wanting to use thrid party tools, but I assume its that you don't want some nasty interop to programmatically do it through another piece of software.
I recommend using ICSharpCode SharpZipLib
This can be added to your project as a reference DLL and is fairly straightforward for creating ZIP files and reading them.
http://www.codeplex.com/DotNetZip Source codes are available, so you can see how they do it and write something similiar for yourself
Check out System.IO.Compression.DeflateStream. Youll find a couple of examples on msdn http://msdn.microsoft.com/en-us/library/system.io.compression.deflatestream.aspx
Use System.IO.Packaging in .NET 3.0+.
See this introduction to System.IO.Packaging
If you're able to take a .NET 4.5 dependency, there's a System.IO.Compression.ZipArchive in that universe; see walkthrough article here (via InfoQ news summary article here)