2017-02-27 119 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文件夾中的所有內容。

相關問題