我没有找到" ZipFile中"类中的" System.IO.Com pression"命名空间 [英] I didn't find "ZipFile" class in the "System.IO.Compression" namespace

查看:129
本文介绍了我没有找到" ZipFile中"类中的" System.IO.Com pression"命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不能用在名字空间压缩文件下课System.IO.Com pression我的code是:

I can't use "Zipfile" class in the name space "System.IO.Compression" my code is :

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

namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            string startPath = @"c:\example\start";
            string zipPath = @"c:\example\result.zip";
            string extractPath = @"c:\example\extract";

            ZipFile.CreateFromDirectory(startPath, zipPath, CompressionLevel.Fastest,true);

            ZipFile.ExtractToDirectory(zipPath, extractPath);
        }
    }
}

该错误是:

名称'zip文件'不在当前上下文中存在

The name 'zipfile' does not exist in the current context

我该如何解决呢?

推荐答案

您需要一个DLL引用添加到组装,System.IO.Com pression.FileSystem.dll - 并确保你正在使用。 NET 4.5(因为它不在早期框架存在)。

You need to add a dll reference to the assembly, "System.IO.Compression.FileSystem.dll" - and ensure you are using .NET 4.5 (since it doesn't exist in earlier frameworks).

有关信息,你可以找到装配和.NET版本(S)的从MSDN

For info, you can find the assembly and .NET version(s) from MSDN

这篇关于我没有找到" ZipFile中"类中的" System.IO.Com pression"命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆