-
Jan 2nd, 2018, 10:02 AM
#1
Thread Starter
Hyperactive Member
Code for zip a file
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)
https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx
Imports System.IO
Imports System.IO.Compression
Module Module1
Sub Main()
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
entry.ExtractToFile(Path.Combine(extractPath, entry.FullName))
End If
Next
End Using
End Sub
End Module
-
Jan 2nd, 2018, 10:22 AM
#2
Re: Code for zip a file
It's of no use importing the namespace that a type is a member of if you haven't referenced the assembly it's declared in. Have you done that? The MSDN documentation for every .NET type tells you what assembly it's declared in and what namespace it's a member of. You should read the documentation for the ZipArchive class.
-
Jan 5th, 2018, 05:47 PM
#3
Re: Code for zip a file
Wait.....did MS buy DotNetZip? That API looks a lot like DotNetZip's API.
-
Jan 7th, 2018, 08:30 AM
#4
Re: Code for zip a file
What I do is have 7zip installed (it's free) then simply call it in .Net passing it the parameters on the commandline.
7zip supports a variety of zip formats, including standard zip and gzip.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|