c#程序中的System.IO.Compression.FileSystem.dll
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16860794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
System.IO.Compression.FileSystem.dll in c# program
提问by Lamloumi Afif
I' like to use the dll System.IO.Compression.FileSystem.dllin my project
我喜欢在我的项目中使用 dll System.IO.Compression.FileSystem.dll


the .net framework version is 4.5 and the os is 64. The problem is that the dll is not found.
What is the solution?
.net framework版本是4.5,os是64。问题是找不到dll。
解决办法是什么?
采纳答案by Scott Chamberlain
The namespace is not the same as the dll name (assembly name). from the MSDN page you linked
命名空间与 dll 名称(程序集名称)不同。从您链接的 MSDN 页面
Namespace: System.IO.Compression
Assembly: System.IO.Compression.FileSystem (in System.IO.Compression.FileSystem.dll)
命名空间:System.IO.Compression
程序集:System.IO.Compression.FileSystem(在 System.IO.Compression.FileSystem.dll 中)
So the namespace you need to include is System.IO.Compressionnot System.IO.Compression.FileSystem. Take off the FileSystempart from your usingstatement and it will solve your problem.
所以你需要包含的命名空间System.IO.Compression不是System.IO.Compression.FileSystem. FileSystem从你的using陈述中去掉这部分,它会解决你的问题。
If people are down-voting me because the OP said "The problem is that the dll is not found." I think the OP is not using the correct word choice, if the problem really was that the DLL could not be found there would be a exclamation point by the assembly name which the original screenshot does not have
如果人们因为 OP 说“问题是找不到 dll”而对我投反对票。我认为 OP 没有使用正确的单词选择,如果问题确实是找不到 DLL,那么原始屏幕截图没有的程序集名称会出现感叹号
See the original image below
请参阅下面的原始图像
Compare that to my screenshot I created that would show up if the DLL really was not found, note the exclamation point I have that the original screenshot does not.
将其与我创建的屏幕截图进行比较,如果确实找不到 DLL,则会显示该屏幕截图,请注意我的感叹号是原始屏幕截图没有的。


回答by codingadventures
in the System.IO.Compression there's no such class as FileSystem check it out the link on the msdn
在 System.IO.Compression 中没有像 FileSystem 这样的类,请查看msdn上的链接
the classes available are:
可用的类是:
- DeflateStream Provides methods and properties for compressing and decompressing streams by using the Deflate algorithm.
- GZipStream Provides methods and properties used to compress and decompress streams.
- ZipArchive Represents a package of compressed files in the zip archive format.
- ZipArchiveEntry Represents a compressed file within a zip archive.
- ZipFile Provides static methods for creating, extracting, and opening zip archives.
- ZipFileExtensions
- DeflateStream 提供使用 Deflate 算法压缩和解压缩流的方法和属性。
- GZipStream 提供用于压缩和解压缩流的方法和属性。
- ZipArchive 表示 zip 存档格式的压缩文件包。
- ZipArchiveEntry 表示 zip 存档中的压缩文件。
- ZipFile 提供用于创建、提取和打开 zip 档案的静态方法。
- 压缩文件扩展名
if your goal is to use compression of file or stream use the GZipStreamclass.
如果您的目标是使用文件或流压缩,请使用GZipStream类。
However remove the FileSystem from the using statement:
但是从 using 语句中删除 FileSystem :
using System.IO.Compression;
Anyway as Joe Enos has pointed out classes from the Compression namespace have been taken out the Client Profile from the framework 4.5
无论如何,正如 Joe Enos 指出的那样,来自 Compression 命名空间的类已经从框架 4.5 中删除了客户端配置文件
Below the Version Information from the msdn about the GZipStream:
在 msdn 关于 GZipStream 的版本信息下面:
.NET Framework Supported in: 4.5, 4, 3.5, 3.0, 2.0
.NET Framework Client Profile Supported in: 4, 3.5 SP1
.NET Framework 受以下版本支持:4.5、4、3.5、3.0、2.0
.NET Framework 客户端配置文件受以下版本支持:4、3.5 SP1
回答by lnaie
A new nuget package is coming out. Check this out :)
一个新的 nuget 包即将推出。看一下这个 :)
https://www.nuget.org/packages/System.IO.Compression.ZipFile
https://www.nuget.org/packages/System.IO.Compression.ZipFile
回答by Gulfraz
Adding reference to System.IO.Compression.dll solved this issue for me.
添加对 System.IO.Compression.dll 的引用为我解决了这个问题。

