2017-02-27 59 views
0

我试图使用ZipFile中包含的功能,但无法获取要包含的名称空间。我有一个项目,并已成功引用System.IO.Compression但尝试引用System.IO.Compression.FileSystem当我得到:即使被引用但不包含System.IO.Compression.FileSystem但不包括

类型命名空间名称“文件系统”并不命名空间中存在“System.IO.Compression”

当我打电话ZipFile我得到

名称“的ZipFile不会在目前的背景下存在

我正在运行.net 4.5.2,所以我应该可以访问这些功能。我不知道发生了什么事,因为看起来我正在做的一切正确。

我已经尝试在Visual Studio中添加两个引用,其中包括它在References文件夹中但我不能在我的处理程序中使用它。

任何帮助将是伟大的,谢谢!

我目前使用指令:

using System.IO.Compression; 

我引用System.IO.Compression.FileSystem.dll我的项目中,以及因此该错误不作出任何意义。

尝试使用的ZipFile:

string startPath = @"c:\example\start"; 
string zipPath = @"c:\example\result.zip"; 
string extractPath = @"c:\example\extract"; 

ZipFile.CreateFromDirectory(startPath, zipPath); 
ZipFile.ExtractToDirectory(zipPath, extractPath); 

The directories within the variables don't exist but that doesn't matter because ZipFile isn't even being found. 

使用指令:

enter image description here

我的项目,参考文献:

enter image description here

+0

使用指令与参考不同。如果成功添加了引用(引用上没有警告图标,错误列表中没有警告),则可以使用using伪指令从引用的项目中引用来自引用程序集的名称空间。 – CodeCaster

+0

感谢您提供的非常有用的评论......我已经尝试过几乎所有“解决方案”,所以似乎没有任何解决方案可以解决。我是这种语言的新手,根据我的理解,它应该像引用它并使用它一样简单。 –

+0

不要粗鲁,但你甚至读过这个问题吗?我已经在我的项目中引用了'System.IO.Compression.FileSystem.dll'。 –

回答

0

的问题是,我的处理程序WASN”为tha创建t项目。我最终为该项目创建了一个新的处理程序,并且可以访问我的References文件夹中的所有内容。

相关问题