Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Zip A folder in .net framework 4.0

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

like image 219
charu Avatar asked Apr 20 '17 05:04

charu


1 Answers

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

%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.


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 Browse tab and locate the file mentioned above.

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

like image 173
Visual Vincent Avatar answered Oct 31 '22 22:10

Visual Vincent