ZipFile Class

IC Sharp Sharp Zip Lib

ICSharpCode SharpZipLib Class 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. You can also update the archive adding or deleting entries. This class is thread safe for input: 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, IDisposable

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)
    {
        using (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) {
                if ( e.IsFile ) {
                    DateTime d = e.DateTime;
                    Console.WriteLine("{0, -10}{1, -10}{2}  {3}   {4}", e.Size, e.CompressedSize,
                        d.ToString("dd-MM-yy"), d.ToString("HH:mm"),
                        e.Name);
                }
            }
        }
    }
}

Requirements

Namespace: ICSharpCode.SharpZipLib.Zip

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

See Also

ZipFile Members | ICSharpCode.SharpZipLib.Zip Namespace