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
How to Zip A folder in .net framework 4.0
提问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:
添加对项目的引用:
Right-click the project node in the
Solution Explorer.(Image credit: another Stack Overflow question)
Press
Add Reference....Go to the
Browsetab and locate the file mentioned above.
右键单击
Solution Explorer.(图片来源:另一个堆栈溢出问题)
按
Add Reference...。转到
Browse选项卡并找到上面提到的文件。
How to: Add or Remove References By Using the Add Reference Dialog Box


