Results 1 to 4 of 4

Thread: Code for zip a file

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2010

    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)


    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
    End Using
    End Sub

    End Module

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Sydney, Australia

    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.

  3. #3
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011

    Re: Code for zip a file

    Wait.....did MS buy DotNetZip? That API looks a lot like DotNetZip's API.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. -jmcilhinney

  4. #4
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Lansing, MI; USA

    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


Click Here to Expand Forum to Full Width