本文介绍了包括System.IO.Compression时,当前上下文中不存在名称“ ZipFile”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我当前正在运行.net 4.5版,并尝试使用它的新 zip功能。我包含了 System.IO.Compression ,并试图运行以下代码:

I"m currently running .net version 4.5 and am trying to use it's "new" zip functions. I'm including System.IO.Compression and am trying to run the following code:

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

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

我遇到的问题是名称'ZipFile在当前上下文中不存在。我不知道为什么如果我不存在它

The issue I'm getting is that The name 'ZipFile does not exist in the current context. I don't know why it wouldn't exist if I'm already using what requires it.

推荐答案

您是否尝试过将命名空间添加到当前文件中?

Have you tried adding the namespace to your current file? To do this add this to the top of the file.

 using System.IO.Compression;

这篇关于包括System.IO.Compression时,当前上下文中不存在名称“ ZipFile”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-09 23:24