本文介绍了包含 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:examplestart";
string zipPath = @"c:example
esult.zip";
string extractPath = @"c:exampleextract";

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