C#中的Zip文件夹 [英] Zip folder in C#

查看:34
本文介绍了C#中的Zip文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C#中如何压缩文件夹的示例(简单代码)是什么?

What is an example (simple code) of how to zip a folder in C#?

更新:

我没有看到命名空间 ICSharpCode.我下载了 ICSharpCode.SharpZipLib.dll 但我不知道在哪里复制那个 DLL 文件.我需要做什么才能看到这个命名空间?

I do not see namespace ICSharpCode. I downloaded ICSharpCode.SharpZipLib.dll but I do not know where to copy that DLL file. What do I need to do to see this namespace?

你有那个压缩文件夹的 MSDN 示例的链接吗,因为我阅读了所有 MSDN 但我找不到任何东西.

And do you have link for that MSDN example for compress folder, because I read all MSDN but I couldn't find anything.

好的,但我需要下一个信息.

OK, but I need next information.

我应该在哪里复制 ICSharpCode.SharpZipLib.dll 以在 Visual Studio 中查看该命名空间?

Where should I copy ICSharpCode.SharpZipLib.dll to see that namespace in Visual Studio?

推荐答案

这个答案随着 .NET 4.5 而改变.创建 zip 文件 变成非常容易.不需要第三方库.

This answer changes with .NET 4.5. Creating a zip file becomes incredibly easy. No third-party libraries will be required.

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

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

这篇关于C#中的Zip文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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