Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 10 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(11)
看看我的小图书馆:https://github.com/jaime-olivares/zipstorer
Have a look to my small library: https://github.com/jaime-olivares/zipstorer
如果您想使用 7-zip 压缩,请查看 Peter Bromberg 的 EggheadCafe 文章。 注意:c# 的 LZMA 源代码 没有 xml 注释(实际上,注释很少根本没有)。
If you want to use 7-zip compression, check out Peter Bromberg's EggheadCafe article. Beware: the LZMA source code for c# has no xml comments (actually, very few comments at all).
如果您不想使用外部组件,这里是我昨晚使用 .NET 的 ZipPackage 类开发的一些代码。
需要注意的事项:
ZIP 存档的根目录中必须有一个 [Content_Types].xml 文件。 这对于我的要求来说不是问题,因为我将控制通过此代码提取的任何 ZIP 文件的压缩。 有关 [Content_Types].xml 文件的详细信息,请参阅:http:// /msdn.microsoft.com/en-us/magazine/cc163372.aspx 本文图 13 下面有一个示例文件。
我尚未测试 CopyStream 方法以确保其行为正确,因为我最初是使用 Stream.CopyTo() 方法为 .NET 4.0 开发此方法。
If you do not want to use an external component, here is some code I developed last night using .NET's ZipPackage class.
Things to note:
The ZIP archive MUST have a [Content_Types].xml file in its root. This was a non-issue for my requirements as I will control the zipping of any ZIP files that get extracted through this code. For more information on the [Content_Types].xml file, please refer to: http://msdn.microsoft.com/en-us/magazine/cc163372.aspx There is an example file below Figure 13 of the article.
I have not tested the CopyStream method to ensure it behaves correctly, as I originally developed this for .NET 4.0 using the Stream.CopyTo() method.
我会推荐我们的 http://www.rebex.net/zip.net/ 但是我有偏见。 下载试用版并自行检查功能和示例。
I would recommend our http://www.rebex.net/zip.net/ but I'm biased. Download trial and check the features and samples yourself.
SevenZipSharp 是 7z.dll 和 LZMA SDK 的包装,它是开源且免费的。
SevenZipSharp is a wrapper around tha 7z.dll and LZMA SDK, which is Open-source, and free.
GPL
http://www.icsharpcode.net/OpenSource/SharpZipLib/
或以下限制性 Ms-PL
http://www.codeplex.com/DotNetZip
要完成此答案,.net框架有 ZipPackage 我的成功率较低它。
The GPL
http://www.icsharpcode.net/OpenSource/SharpZipLib/
OR the less restrictive Ms-PL
http://www.codeplex.com/DotNetZip
To complete this answer the .net framework has ZipPackage I had less success with it.
如果您只想将文件的内容解压缩到文件夹,并且您知道您只能在 Windows 上运行,则可以使用 Windows Shell 对象。 在此示例中,我使用了 Framework 4.0 中的
dynamic
,但您可以使用Type.InvokeMember
获得相同的结果。您可以使用 FILEOP_FLAGS 来控制
CopyHere方法。
If all you want to do is unzip the contents of a file to a folder, and you know you'll only be running on Windows, you can use the Windows Shell object. I've used
dynamic
from Framework 4.0 in this example, but you can achieve the same results usingType.InvokeMember
.You can use FILEOP_FLAGS to control behaviour of the
CopyHere
method.DotNetZip 易于使用。 这是一个解压缩示例
如果您有更复杂的需求,例如您想要选择要提取的条目,或者是否有密码,或者如果您想控制提取的文件的路径名,等等,那么这里有很多选择。 查看帮助文件以获取更多示例。
DotNetZip 是免费且开源的。
DotNetZip is easy to use. Here's an unzip sample
If you have more complex needs, like you want to pick-and-choose which entries to extract, or if there are passwords, or if you want to control the pathnames of the extracted files, or etc etc etc, there are lots of options. Check the help file for more examples.
DotNetZip is free and open source.
过去,我使用过 DotNetZip (MS-PL)、SharpZipLib (GPL) 和 适用于 C# 的 7ZIP SDK(公共领域)。 它们都工作得很好,而且都是开源的。
在这种情况下,我会选择 DotNetZip,这里有一些来自 C# 示例页面< 的示例代码/a>:
In the past, I've used DotNetZip (MS-PL), SharpZipLib (GPL), and the 7ZIP SDK for C# (public domain). They all work great, and are open source.
I would choose DotNetZip in this situation, and here's some sample code from the C# Examples page:
SharpZipLib
http://www.icsharpcode.net/OpenSource/SharpZipLib/
SharpZipLib
http://www.icsharpcode.net/OpenSource/SharpZipLib/