Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8441197
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:30:17+00:00 2026-06-10T08:30:17+00:00

I am a programmer using VS2012. I am wanting to unzip a zip file

  • 0

I am a programmer using VS2012. I am wanting to unzip a zip file (made with Winzip, filzip or other zip compression routines) and then also be able to zip the files back up into a zip file.

What is the best library to use for this and can I please have some sample code on how to use the library?

EDIT

I am using VB.net, here is my code:

Public Function extractZipArchive() As Boolean
    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 Function

What import statements do I need to use?
Currently I have added the following:

Imports System.IO
Imports System.IO.Compression

I am getting the error:

Type ‘ZipArchive’ is not defined

How can I fix this error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T08:30:19+00:00Added an answer on June 10, 2026 at 8:30 am

    If you’re using Visual Studio 2012 and the .NET Framework 4.5 you can use the new compression library:

        //This stores the path where the file should be unzipped to,
        //including any subfolders that the file was originally in.
        string fileUnzipFullPath;
         
        //This is the full name of the destination file including
        //the path
        string fileUnzipFullName;
         
        //Opens the zip file up to be read
        using (ZipArchive archive = ZipFile.OpenRead(zipName))
        {
            //Loops through each file in the zip file
            foreach (ZipArchiveEntry file in archive.Entries)
            {
                //Outputs relevant file information to the console
                Console.WriteLine("File Name: {0}", file.Name);
                Console.WriteLine("File Size: {0} bytes", file.Length);
                Console.WriteLine("Compression Ratio: {0}", ((double)file.CompressedLength / file.Length).ToString("0.0%"));
         
                //Identifies the destination file name and path
                fileUnzipFullName = Path.Combine(dirToUnzipTo, file.FullName);
         
                //Extracts the files to the output folder in a safer manner
                if (!System.IO.File.Exists(fileUnzipFullName))
                {
                    //Calculates what the new full path for the unzipped file should be
                    fileUnzipFullPath = Path.GetDirectoryName(fileUnzipFullName);
                                
                    //Creates the directory (if it doesn't exist) for the new path
                    Directory.CreateDirectory(fileUnzipFullPath);
         
                    //Extracts the file to (potentially new) path
                    file.ExtractToFile(fileUnzipFullName);
                }
            }
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have noticed some programmer using COMMIT other using conn.setAutoCommit(true); to end the transaction
I am a student programmer using Qt to build a GUI interface fro my
I am a student programmer using QT to develop and application for work. Currently
I have a programmer who is using VB and LINQ; and I have a
I am using Emacs and Rudel to collaborate with a remote programmer. Rudel has
Rookie C++ Programmer here again I'm using VC++ VS2008 and making an attempt at
I am a Java programmer and was working on a project using Hibernate and
I am a beginner programmer, using python on Mac. I created a function as
I recall when I first read Pragmatic Programmer that they suggested using scripting languages
I'm a new Python programmer who is having a little trouble using 'self' in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.