简体   繁体   English

VS 2010中的System.IO.Compression.FileSystem程序集

[英]System.IO.Compression.FileSystem assembly in VS 2010

I'm trying to compile this simple code in my C# WinForms project in VS 2010: 我试图在VS 2010的C#WinForms项目中编译以下简单代码:

using System.IO;
using System.IO.Compression;

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

using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
    foreach (ZipArchiveEntry entry in archive.Entries)
    {
        if (entry.FullName.EndsWith(".txt", StringComparison.OrdinalIgnoreCase))
        {
            entry.ExtractToFile(Path.Combine(extractPath, entry.FullName));
        }
    }
}

The description for the ZipFile Class tells me that I need to add System.IO.Compression.FileSystem assembly. ZipFile类的描述告诉我,我需要添加System.IO.Compression.FileSystem程序集。 Sorry for this question, but where the heck is it? 很抱歉这个问题,但是到底在哪里呢? Does it come as a DLL? 它以DLL的形式出现吗? It is not in the list of the .NET references, and I know for sure that I have .NET Framework v.4.5 installed. 它不在.NET参考列表中,而且我可以肯定知道已经安装了.NET Framework v.4.5。

EDIT : Whoever wants to include a simple Zip archive support in your VS 2010 project, I found this project that compiles right into your own project. 编辑 :谁想要在您的VS 2010项目中包括一个简单的Zip存档支持,我都会发现此项目可以直接编译到您自己的项目中。 Very clean and simple. 非常干净和简单。

You may have the .NET 4.5 framework installed, but you need to have VS 2012 to use components from it when developing programs in 4.5. 您可能已安装.NET 4.5框架,但是在4.5中开发程序时,需要具有VS 2012才能使用其中的组件。

VS 2010 supports .NET 2.0, 3.0, 3.5 and 4.0, but not 4.5. VS 2010支持.NET 2.0、3.0、3.5和4.0,但不支持4.5。

VS 2012 supports all of the above plus .NET 4.5. VS 2012支持以上所有功能以及.NET 4.5。 The ZipFile Class is new in 4.5, there are no earlier versions of it (according to the MSDN link, at least). ZipFile类是4.5中的新增功能,没有早期版本(至少根据MSDN链接)。

If you don't want to buy VS 2012, you can check into the Visual Studio Express 2012 Products , which are free. 如果您不想购买VS 2012,则可以免费使用Visual Studio Express 2012产品

You can use Visual Studio 2010 and it does support it, provided your OS supports .NET 4.5. 如果您的操作系统支持.NET 4.5,则可以使用Visual Studio 2010并支持它。
I know this because I use Visual Studio 2010 on Windows 8. 我知道这是因为我在Windows 8上使用Visual Studio 2010。

Right click on your solution to add a reference (as you do). 右键单击您的解决方案以添加参考(如您所愿)。 When the dialog box shows, select browse, then navigate to the following folder: 显示对话框时,选择浏览,然后导航到以下文件夹:

C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.5

You will find it there. 您会在那找到它。

I had the same issue a while back. 我前一段时间也遇到过同样的问题。

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM