ZipFile Class

SharpZip Compression Library

SharpZip Compression Library

ZipFile Class

This class represents a Zip archive. You can ask for the contained entries, or get an input stream for a file entry. The entry is automatically decompressed. This class is thread safe: You can open input streams for arbitrary entries in different threads.

Author of the original java version : Jochen Hoenicke

For a list of all members of this type, see ZipFile Members.

System.Object
   ICSharpCode.SharpZipLib.Zip.ZipFile

public class ZipFile : IEnumerable

Thread Safety

Public static (Shared in Visual Basic) members of this type are safe for multithreaded operations. Instance members are not guaranteed to be thread-safe.

Example

using System;
using System.Text;
using System.Collections;
using System.IO;

using ICSharpCode.SharpZipLib.Zip;

class MainClass
{
    static public void Main(string[] args)
    {
        ZipFile zFile = new ZipFile(args[0]);
        Console.WriteLine("Listing of : " + zFile.Name);
        Console.WriteLine("");
        Console.WriteLine("Raw Size    Size      Date     Time     Name");
        Console.WriteLine("--------  --------  --------  ------  ---------");
        foreach (ZipEntry e in zFile) {
            DateTime d = e.DateTime;
            Console.WriteLine("{0, -10}{1, -10}{2}  {3}   {4}", e.Size, e.CompressedSize,
                                                                d.ToString("dd-MM-yy"), d.ToString("t"),
                                                                e.Name);
        }
    }
}

Requirements

Namespace: ICSharpCode.SharpZipLib.Zip

Assembly: ICSharpCode.SharpZipLib (in ICSharpCode.SharpZipLib.dll)

See Also

ZipFile Members | ICSharpCode.SharpZipLib.Zip Namespace