Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 11 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
在 .NET Framework 4.5 中,现在有 System.IO.Compression.ZipFile.ExtractToDirectory(String, String) 方法。
In .NET framework 4.5 now there is
System.IO.Compression.ZipFile.ExtractToDirectory(String, String)
method.我不确定它在 VS2010 中是否仍然可用,但在早期版本中,J# 包含在 VS 中,并且 J# 包含 vjslib.dll 中的 java.util.zip 类,因为它是 VS 的一部分,它不是第三方 DLL,因此您也许可以这样做。
以下 CodeProject 文章展示了如何执行此操作: 使用 J# 运行时从 C# 程序中压缩和解压缩
I'm not sure if it's still available in VS2010, but in earlier versions J# was included in VS and J# includes the
java.util.zip
class in the vjslib.dll, and since it's part of VS, it's not a third party DLL so you might be able to do it that way.Here's a CodeProject article showing how to do this: Zip and Unzip from a C# program using J# runtime
没有“好的”方法可以做到这一点。显然,您可以使用公开的信息自行实现 ZIP 算法ZIP 文件结构和类,例如 DeflateStream(尽管如果不使用 DEFLATE 算法进行压缩,这也可能不起作用)。 这篇博文,但简短的版本是您要么必须使用第三方库,要么自己重写一个。
如果在这种情况下您能够以 GPL 方式发布源代码,您可以从诸如 SharpZipLib 到您自己的目录中,从而回避使用 DLL 的要求。除此之外,为什么不能使用第三方 DLL?
There is no "good" way to do this. You could obviously implement the ZIP algorithm yourself using publicly available information on the ZIP file structure and classes such as DeflateStream (though even this may not work if it is not compressed using the DEFLATE algorithm). There is some information on possible alternatives in this blog post, but the short version is that you will either have to use a third-party library or re-write one yourself.
If this is a situation where you would be able to release the source code in a GPL'd manner, you could copy-paste the code from a project like SharpZipLib into your own, thereby sidestepping the requirement to use the DLL. Other than that, though, why can't you use third-party DLLs?
.NET 框架本身(当前)不提供对 ZIP 文件的官方支持。正如其他人指出的那样,有几个可用的高质量第三方免费库,并且 J# 运行时支持它。
我推荐第三方解决方案,但如果您绝对不能这样做,那么还有另一个技巧: ZipPackage,它是 WPF 的一部分。它在某种程度上支持 ZIP 文件(通过额外的元数据增强),并且足以读取大多数 ZIP 文件。
The .NET framework itself does not (currently) have official support for ZIP files. There are a couple of high-quality third-party free libraries available, and the J# runtime supports it, as others have noted.
I recommend the third-party solution, but if you absolutely can't do that, then there is one other trick: ZipPackage, which is part of WPF. It sort-of supports ZIP files (augmented with extra metadata), and works well enough for reading most ZIP files.
GZipStream 最常用于 WCF 数据压缩。不要在这里使用它。
您可以尝试将此 ZIP 库压缩为文件:
http://www.icsharpcode.net/opensource/ Sharpziplib/
GZipStream is most commonly used for WCF data compression. Dont use that here.
You can try this ZIP library to compress into files:
http://www.icsharpcode.net/opensource/sharpziplib/
谷歌快速搜索发现了这一点。
GZipStream 类 MSDN 参考
A quick google search turned this up.
GZipStream Class MSDN Reference