vb.net 如何在 .net framework 4.0 中压缩文件夹

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43510956/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 20:15:41  来源:igfitidea点击:

How to Zip A folder in .net framework 4.0

.netvb.net.net-4.0zipzipfile

提问by charu

How to zip a folder using vb.net and in .net framework 4.0. I am able to do this by using ZipFile class which is available in framework 4.5 but I need to use only framework 4.0 and also no third party library. Please help

如何使用 vb.net 和 .net framework 4.0 压缩文件夹。我可以通过使用框架 4.5 中提供的 ZipFile 类来做到这一点,但我只需要使用框架 4.0,也不需要第三方库。请帮忙

采纳答案by Visual Vincent

Actually you can use the ZipFileclass in .NET 4.0 as well. You just gotta add a reference to the System.IO.Compression.FileSystem.dllfile, located in:

实际上,您也可以ZipFile在 .NET 4.0 中使用该类。您只需添加对System.IO.Compression.FileSystem.dll文件的引用,该文件位于:

%SystemRoot%\Microsoft.NET\assembly\GAC_MSIL\System.IO.Compr??????ession.FileSyste??m\??v4??.0_4.0.0.0__??b77a??5c56??1934e089??\Syste??m.IO.C??ompr??ession.F??ileSyste????m.dll

As you see it is located in the "v4.0" folder, so it exists in .NET 4.0, but for some reason isn't referenced automatically.

如您所见,它位于“v4.0”文件夹中,因此它存在于 .NET 4.0 中,但由于某种原因未自动引用。



To add a reference to your project:

添加对项目的引用:

  1. Right-click the project node in the Solution Explorer.

    Solution Explorer

    (Image credit: another Stack Overflow question)

  2. Press Add Reference....

  3. Go to the Browsetab and locate the file mentioned above.

  1. 右键单击Solution Explorer.

    解决方案资源管理器

    (图片来源:另一个堆栈溢出问题

  2. Add Reference...

  3. 转到Browse选项卡并找到上面提到的文件。

How to: Add or Remove References By Using the Add Reference Dialog Box

如何:使用“添加引用”对话框添加或删除引用