包括System.IO.Compression时,当前上下文中不存在名称“ ZipFile”

编程入门 行业动态 更新时间:2024-10-20 06:23:31
本文介绍了包括System.IO.Compression时,当前上下文中不存在名称“ ZipFile”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I"m currently running 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”

本文发布于:2023-11-09 20:44:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1573392.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:上下文   中不   名称   IO   System

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!