ZipFile does not exist in the current context!

Hemanth B 886 Reputation points
2021-06-08T06:55:30.387+00:00

I want to extract a zip file in a specific location to another location: The code is below: But it says "ZipFile does not exist in the current context" in the 4th line of code. Please help! Please provide an correct code that can extract zip files!

string zipPath = @"C:\Users\bnara\Documents\text.zip";
string extractionPath = @"C:\Users\bnara\Pictures\text.zip";
ZipFile.ExtractToDirectory(zipPath, extractionPath);
MessageBox.Show("Extracted Successfully");

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,427 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Viorel 121.3K Reputation points
    2021-06-08T07:35:34.09+00:00

    Add a reference to System.IO.Compression.FileSystem assembly if you already know how.

    Also add this line to the beginning of your file:

    using System.IO.Compression;

    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.