.NET 的开源 zip 库?

发布于 2024-07-10 02:18:47 字数 1557 浏览 8 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

|煩躁 2024-07-17 02:18:47

SharpZipLib

关于内部 gzip 实现的评论和其他帖子,它们相同!GZip 不会创建归档所需的标头; 它仅适用于“压缩”一个文件或流。

正确的 zip 存档包含一个标头,其中列出了所有压缩文件以及它们在压缩数据中的位置,因此您需要一些可以制作标头的东西。 这意味着 SharpZipLib,它是众多商业版本之一,或者使用带有 .NET 绑定的外部版本,例如 7zip。

偶然有人想说:“但是我一直在 Linux 中看到 .gz 文件!” - 它们只是单个文件,.tar.gz 也不例外 - tar 是存档文件。 .gz 是压缩的存档。

SharpZipLib

Regarding the comments and other posts about the internal gzip implementation, they are not the same! GZip does not create the header required for archiving; it is only useful for "zipping" one file or stream.

Proper zip archives contain a header that list all compressed files and where in the compressed data they come and therefore you need something that makes a header. That means SharpZipLib, one of the many commercial versions or using something external with .NET bindings like 7zip.

Just on the offchance somebody wants to say this: "But I see .gz files in Linux all the time!" - they're just single files and .tar.gz is no exception - tar is the archive file. The .gz is that archive compressed.

偏爱你一生 2024-07-17 02:18:47

情侣评论。

  1. 不要使用 J# 运行时。 J# 已被 Microsoft 终止。 未来的支持值得怀疑。 此外,当您想要的只是 ZIP 支持时,整个 J# 运行时是一个难以忍受的大难题。
  2. System.IO.Compression 中的 GzipStream(自 .NET 2.0 起成为 .NET 基类库的一部分)为 IETF RFC-1952 压缩。 压缩是可以的,虽然压缩率不是最优的,并且会显着扩展之前压缩过的数据。 此错误已报告给 Microsoft,但显然已被关闭。 还有一个类似的 DeflateStream,但适用于 RFC 1951。 人们普遍误解 GZipStream 可以压缩文件。 不对。 这两个都不支持 zip 文件。
  3. 有 System.IO.Packaging.ZipPackage。 它可以工作,但主要设计用于打包 MS Office 2007(.docx、.xslx 和 .pptx)文件。 它对于 zip 文件来说很笨重,并且不支持许多 ZIP 功能,例如加密。
  4. 如果您想要一种灵活的方式在 .NET 中创建和读取 zip 文件,目前您需要一个第 3 方库。

DotNetZip 是一个很好的第 3 方选项。 免费、开源、积极维护、使用简单、小而良好的功能集。 它作为单个程序集提供 - 它是完全托管的代码。 适用于 Compact Framework 以及常规 .NET Framework。 先决条件是.NET 2.0。

DotNetZip 还包括一个 ZLIB 库,其中包含 {Zlib,GZip,Deflate}Stream 等类。 它们与 .NET 中内置的类相当,但它们包含设置压缩级别的功能,并且在更高级别上,它们比内置类压缩得更有效。 ZlibStream 进行 RFC 1950 压缩。

DotNetZip 支持 ZIP64、密码、AES 加密、流、SFX 和 Unicode。 每个使用它的人都说它比 SharpZipLib 使用起来简单得多。 有一个很好的帮助文件 (.chm) 和大量代码示例。

DNZ CHM

Couple comments.

  1. Don't use the J# runtime. J# has been discontinued by Microsoft. Future support is questionable. Also, the entire J# runtime is a big nut to swallow when all you want is ZIP support.
  2. The GzipStream in System.IO.Compression, part of the .NET base class library since .NET 2.0, provides a stream interface for IETF RFC-1952 compression. It is ok for compression, though the compression ratio is not optimal and it will significantly expand data that has been previously compressed. This bug was reported to Microsoft, but it's apparently been closed. There is also a DeflateStream which is similar, but for RFC 1951. There's a common misconception that GZipStream does zip files. Not true. Neither of these two do zip files.
  3. There's System.IO.Packaging.ZipPackage. It works, but is designed and intended primarily for packaging of MS Office 2007 (.docx, .xslx, and .pptx) files. It's unwieldy for zip files and doesn't support lots of ZIP features, like encryption.
  4. If you want a flexible way to create and read zip files in .NET you need a 3rd party library, currently.

DotNetZip is a good 3rd party option. Free, open source, actively maintained, simple to use, small, good feature set. It is shipped as a single assembly - it is fully managed code. Works on Compact Framework as well as on the regular .NET Framework. The pre-req is .NET 2.0.

DotNetZip also includes a ZLIB library, with classes like {Zlib,GZip,Deflate}Stream. They are comparable to those built-in to .NET, but they include the ability to set Compression Levels, and at higher levels they compress much more effectively than the built-in classes. The ZlibStream does RFC 1950 compression.

DotNetZip does ZIP64, passwords, AES encryption, streams, SFX, and Unicode. Everyone who uses it says it is much simpler to use than SharpZipLib. There's a good help file (.chm) and lots of code examples.

DNZ CHM

思念满溢 2024-07-17 02:18:47

DotNet Zip 库 (Ionic.Zip.dll) 非常易于使用。 我觉得它比 SharpZip 更容易实现。

http://www.codeplex.com/DotNetZip

The DotNet Zip Library (Ionic.Zip.dll) is very easy to use. I feel that it's easier to implement than SharpZip.

http://www.codeplex.com/DotNetZip

花桑 2024-07-17 02:18:47

尝试查看 7-zip。 它是开源的,也是我最喜欢的 zip 程序。 非常混乱。 还利用了多核的优势。

.NET SDK 可在此处获取。

Try checking out 7-zip. It's open source and my fav zip program. very kewl. takes advantage of multi cores also.

The .NET SDK is available here.

莫言歌 2024-07-17 02:18:47

**** 但是 .NET 已经支持开源 zip....****

http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream.aspx

这与 GZIP 库兼容。 我用它来压缩 C# 数据并在 C++ 应用程序中通过网络解压缩。 工作正常。

托尼

**** But guys .NET Already supports open source zip....****

http://msdn.microsoft.com/en-us/library/system.io.compression.gzipstream.aspx

This is compatible with the GZIP libraries. I used this to compress c# data and decompress across the network in a C++ application. Works fine.

Tony

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文