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?

JleruOHeP
  • 10,106
  • 3
  • 45
  • 71
user1073024
  • 79
  • 2
  • 4

1 Answers1

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);
}
citronas
  • 19,035
  • 27
  • 96
  • 164
  • 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 . – user1073024 Jan 02 '13 at 09:36