0

I want to read a file from a zip folder in Asp.net 2.0 using C# . actually i want something like this :

using (ZipFile zip = ZipFile.Open(@"E:\MyZipFolder.ZIP", FileAccess.Read))
{
    // Read the central directory collection
    List<ZipFile.ZipFileEntry> dir = zip.ReadCentralDir();

    // Look for the desired file
    foreach (ZipFile.ZipFileEntry entry in dir)
    {
        if (Path.GetFileName(entry.FilenameInZip) == "MyZipFile.jpg")
        {
            // File found, extract it
            zip.ExtractStoredFile(entry, @"E:\ExtractFolder\MyZipFile.jpg");
            break;
        }
    }
}

ZipFile is unknown , is there any suggestion?

4
  • 1
    What does mean "ZipFile is unknown"? Commented Dec 28, 2012 at 10:03
  • Take a look here: stackoverflow.com/questions/5967864/… Commented Dec 28, 2012 at 10:04
  • 1
    ZipFile is 4.5 feature, for asp.net 2.0 you can use ziplib Commented Dec 28, 2012 at 10:04
  • You could also check the System.IO.Packaging classes in .NET 3.0+ Commented Dec 28, 2012 at 10:06

1 Answer 1

2

Have a look into DotNetZip Library instead.

To use the zip capability in your applications, you need to be using the .NET Framework 2.0 or later, and you need the DotNetZip Devkit assembly.

Edit: To extract a file by name:

From http://dotnetzip.herobo.com/DNZHelp/Index.html# "Navigation: Code Examples -> C#"

using (ZipFile zip = ZipFile.Read(ExistingZipFile))
{
  ZipEntry e = zip["MyReport.doc"];
  e.Extract(OutputStream);
}
Sign up to request clarification or add additional context in comments.

1 Comment

I Use .net framework 2.0 and download ionic.zip.dll but actually i want to know how can i extract just one of those files which are in a zip file because my zip file is too large and i don't want to extract all files in my web application . please guide how can i do it .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.