Last post Jan 03, 2018 06:40 AM by Cathy Zou
Jan 02, 2018 03:03 PM|aspfun|LINK
I want to learn zip file from the link below but got an error said that "ZipArchive is not defined"
How to fix it?
(I used vs2015, win7, framework 4.5)
Dim zipPath As String = "c:\example\start.zip"
Dim extractPath As String = "c:\example\extract"
Using archive As ZipArchive = ZipFile.OpenRead(zipPath)
For Each entry As ZipArchiveEntry In archive.Entries
If entry.FullName.EndsWith(".txt", StringComparison.OrdinalIgnoreCase) Then
Jan 02, 2018 03:11 PM|PatriceSc|LINK
And you checked the project properties to make 100% sure you are targeting 4.5 or later rather than 4.0 or earlier ???
Jan 02, 2018 03:13 PM|aspfun|LINK
Yes, I checked again.
It is 4.5
Under Imports System.IO.Compression, only list 4 options:
Jan 02, 2018 03:32 PM|PatriceSc|LINK
And compressionMode comes from ? t(his is compressionMode or
What you describe seems to better match
https://msdn.microsoft.com/en-us/library/system.io.compression(v=vs.100).aspx than https://msdn.microsoft.com/en-us/library/system.io.compression(v=vs.110).aspx
Seems really a kind of version issue. Could it be that you created a 4.5 project but added a reference to the 4.0 Compression library ???? Else I try but I'm pretty confident it is expected to just work.
Jan 02, 2018 04:03 PM|aspfun|LINK
I loaded System.IO.Compression.dll and System.IO.Compression.FileSystem.dll from
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1
But, when clicking System.IO.Compression or System.IO.Compression.FileSystem, runtime version in property window showing "v4.0.30319", is it right?
Jan 02, 2018 06:03 PM|oned_gk|LINK
What you mean not working, any error?
Try store the folder in to your site, maybe security issue.
Dim zipPath As String = Path.Combine(Server.MapPath("~/example"),"start.zip")
Jan 02, 2018 06:14 PM|PatriceSc|LINK
Yes, the runtime version doesn't tell much as all version starting from 4.5 are a full replacement for the existing 4.x version.
Instead use "Project", "References" and use the "Assembly" list. It just show the "file version" information. Or browse to the file using the Windows explorer and use check the "Details" tab in the file properties.
Do you see 4.6.1055.0 for both files ? I created a VB project here, checked both assemblies in the "project" "references" dialog and your code just compiles fine.
BTW you really see "compressionMode" rather than "CompressionMode" ? Could be some kind of issue with another compression library you tried earlier ????
Edit: seeing one_gk response and to be on the safe side you currently have a compile time error telling you the ZipArchive type is not defined ??? (which happens on my side only if I comment the "Imports System.IO.Compression" line.
So to me for some reason the ZipArchive type is really not found in the namespace you are using...
Jan 03, 2018 06:40 AM|Cathy Zou|LINK
In order to Unzip and Extract contents of Zip Archive file in ASP.Net we will need to make use of DotNetZipLibrary which is a free Open Source Library for .Net.
Referencing the DotNetZip Library
You will need to download the DotNetZip Library DLL using the Download Link provided below.
Download DotNetZip Or your will find the DLL in the attached sample at the end of the article.
Once you have the DLL you need to place the Ionic.Zip.Reduced.dll in the
You will need to import the following Namespaces
Following working sample for your reference: