Show / Hide Table of Contents

Class FastZip

FastZip provides facilities for creating and extracting zip files.

Inheritance
System.Object
FastZip
Inherited Members
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: ICSharpCode.SharpZipLib.Zip
Assembly: ICSharpCode.SharpZipLib.dll
Syntax
public class FastZip

Constructors

| Improve this Doc View Source

FastZip()

Initialise a default instance of FastZip.

Declaration
public FastZip()
| Improve this Doc View Source

FastZip(FastZipEvents)

Initialise a new instance of FastZip

Declaration
public FastZip(FastZipEvents events)
Parameters
Type Name Description
FastZipEvents events

The events to use during operations.

| Improve this Doc View Source

FastZip(ZipEntryFactory.TimeSetting)

Initialise a new instance of FastZip using the specified ZipEntryFactory.TimeSetting

Declaration
public FastZip(ZipEntryFactory.TimeSetting timeSetting)
Parameters
Type Name Description
ZipEntryFactory.TimeSetting timeSetting

The time setting to use when creating or extracting Zip entries.

Remarks

Using TimeSetting.LastAccessTime[Utc] when creating an archive will set the file time to the moment of reading.

| Improve this Doc View Source

FastZip(DateTime)

Initialise a new instance of FastZip using the specified System.DateTime

Declaration
public FastZip(DateTime time)
Parameters
Type Name Description
System.DateTime time

The time to set all DateTime values for created or extracted Zip Entries.

Properties

| Improve this Doc View Source

CompressionLevel

Get/set the Compression Level that will be used when creating the zip

Declaration
public Deflater.CompressionLevel CompressionLevel { get; set; }
Property Value
Type Description
Deflater.CompressionLevel
| Improve this Doc View Source

CreateEmptyDirectories

Get/set a value indicating whether empty directories should be created.

Declaration
public bool CreateEmptyDirectories { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

EntryEncryptionMethod

Get / set the method of encrypting entries.

Declaration
public ZipEncryptionMethod EntryEncryptionMethod { get; set; }
Property Value
Type Description
ZipEncryptionMethod
Remarks

Only applies when Password is set. Defaults to ZipCrypto for backwards compatibility purposes.

| Improve this Doc View Source

EntryFactory

Get or set the IEntryFactory active when creating Zip files.

Declaration
public IEntryFactory EntryFactory { get; set; }
Property Value
Type Description
IEntryFactory
| Improve this Doc View Source

LegacyCodePage

Gets or sets the code page used for reading/writing zip file entries when unicode is disabled

Declaration
public int LegacyCodePage { get; set; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

NameTransform

Get or set the INameTransform active when creating Zip files.

Declaration
public INameTransform NameTransform { get; set; }
Property Value
Type Description
INameTransform
See Also
EntryFactory
| Improve this Doc View Source

Password

Get / set the password value.

Declaration
public string Password { get; set; }
Property Value
Type Description
System.String
| Improve this Doc View Source

RestoreAttributesOnExtract

Get/set a value indicating whether file attributes should be restored during extract operations

Declaration
public bool RestoreAttributesOnExtract { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

RestoreDateTimeOnExtract

Get/set a value indicating whether file dates and times should be restored when extracting files from an archive.

Declaration
public bool RestoreDateTimeOnExtract { get; set; }
Property Value
Type Description
System.Boolean
Remarks

The default value is false.

| Improve this Doc View Source

StringCodec

Utility class for resolving the encoding used for reading and writing strings

Declaration
public StringCodec StringCodec { get; set; }
Property Value
Type Description
StringCodec
| Improve this Doc View Source

UseUnicode

Reflects the opposite of the internal ForceZipLegacyEncoding, setting it to false overrides the encoding used for reading and writing zip entries

Declaration
public bool UseUnicode { get; set; }
Property Value
Type Description
System.Boolean
| Improve this Doc View Source

UseZip64

Gets or sets the setting for Zip64 handling when writing.

Declaration
public UseZip64 UseZip64 { get; set; }
Property Value
Type Description
UseZip64
Remarks

The default value is dynamic which is not backwards compatible with old programs and can cause problems with XP's built in compression which cant read Zip64 archives. However it does avoid the situation were a large file is added and cannot be completed correctly. NOTE: Setting the size for entries before they are added is the best solution! By default the EntryFactory used by FastZip will set the file size.

Methods

| Improve this Doc View Source

CreateZip(Stream, String, Boolean, IScanFilter, IScanFilter, Boolean)

Create a zip archive sending output to the outputStream passed.

Declaration
public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse, IScanFilter fileFilter, IScanFilter directoryFilter, bool leaveOpen = false)
Parameters
Type Name Description
System.IO.Stream outputStream

The stream to write archive data to.

System.String sourceDirectory

The directory to source files from.

System.Boolean recurse

True to recurse directories, false for no recursion.

IScanFilter fileFilter

The file filter to apply.

IScanFilter directoryFilter

The directory filter to apply.

System.Boolean leaveOpen

true to leave outputStream open after the zip has been created, false to dispose it.

| Improve this Doc View Source

CreateZip(Stream, String, Boolean, String, String)

Create a zip archive sending output to the outputStream passed.

Declaration
public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse, string fileFilter, string directoryFilter)
Parameters
Type Name Description
System.IO.Stream outputStream

The stream to write archive data to.

System.String sourceDirectory

The directory to source files from.

System.Boolean recurse

True to recurse directories, false for no recursion.

System.String fileFilter

The file filter to apply.

System.String directoryFilter

The directory filter to apply.

Remarks

The outputStream is closed after creation.

| Improve this Doc View Source

CreateZip(Stream, String, Boolean, String, String, Boolean)

Create a zip archive sending output to the outputStream passed.

Declaration
public void CreateZip(Stream outputStream, string sourceDirectory, bool recurse, string fileFilter, string directoryFilter, bool leaveOpen)
Parameters
Type Name Description
System.IO.Stream outputStream

The stream to write archive data to.

System.String sourceDirectory

The directory to source files from.

System.Boolean recurse

True to recurse directories, false for no recursion.

System.String fileFilter

The file filter to apply.

System.String directoryFilter

The directory filter to apply.

System.Boolean leaveOpen

true to leave outputStream open after the zip has been created, false to dispose it.

| Improve this Doc View Source

CreateZip(String, String, Boolean, IScanFilter, IScanFilter)

Create a zip file.

Declaration
public void CreateZip(string zipFileName, string sourceDirectory, bool recurse, IScanFilter fileFilter, IScanFilter directoryFilter)
Parameters
Type Name Description
System.String zipFileName

The name of the zip file to create.

System.String sourceDirectory

The directory to source files from.

System.Boolean recurse

True to recurse directories, false for no recursion.

IScanFilter fileFilter

The file filter to apply.

IScanFilter directoryFilter

The directory filter to apply.

| Improve this Doc View Source

CreateZip(String, String, Boolean, String)

Create a zip file/archive.

Declaration
public void CreateZip(string zipFileName, string sourceDirectory, bool recurse, string fileFilter)
Parameters
Type Name Description
System.String zipFileName

The name of the zip file to create.

System.String sourceDirectory

The directory to obtain files and directories from.

System.Boolean recurse

True to recurse directories, false for no recursion.

System.String fileFilter

The file filter to apply.

| Improve this Doc View Source

CreateZip(String, String, Boolean, String, String)

Create a zip file.

Declaration
public void CreateZip(string zipFileName, string sourceDirectory, bool recurse, string fileFilter, string directoryFilter)
Parameters
Type Name Description
System.String zipFileName

The name of the zip file to create.

System.String sourceDirectory

The directory to source files from.

System.Boolean recurse

True to recurse directories, false for no recursion.

System.String fileFilter

The file filter to apply.

System.String directoryFilter

The directory filter to apply.

| Improve this Doc View Source

ExtractZip(Stream, String, FastZip.Overwrite, FastZip.ConfirmOverwriteDelegate, String, String, Boolean, Boolean, Boolean)

Extract the contents of a zip file held in a stream.

Declaration
public void ExtractZip(Stream inputStream, string targetDirectory, FastZip.Overwrite overwrite, FastZip.ConfirmOverwriteDelegate confirmDelegate, string fileFilter, string directoryFilter, bool restoreDateTime, bool isStreamOwner, bool allowParentTraversal = false)
Parameters
Type Name Description
System.IO.Stream inputStream

The seekable input stream containing the zip to extract from.

System.String targetDirectory

The directory to save extracted information in.

FastZip.Overwrite overwrite

The style of overwriting to apply.

FastZip.ConfirmOverwriteDelegate confirmDelegate

A delegate to invoke when confirming overwriting.

System.String fileFilter

A filter to apply to files.

System.String directoryFilter

A filter to apply to directories.

System.Boolean restoreDateTime

Flag indicating whether to restore the date and time for extracted files.

System.Boolean isStreamOwner

Flag indicating whether the inputStream will be closed by this method.

System.Boolean allowParentTraversal

Allow parent directory traversal in file paths (e.g. ../file)

| Improve this Doc View Source

ExtractZip(String, String, FastZip.Overwrite, FastZip.ConfirmOverwriteDelegate, String, String, Boolean, Boolean)

Extract the contents of a zip file.

Declaration
public void ExtractZip(string zipFileName, string targetDirectory, FastZip.Overwrite overwrite, FastZip.ConfirmOverwriteDelegate confirmDelegate, string fileFilter, string directoryFilter, bool restoreDateTime, bool allowParentTraversal = false)
Parameters
Type Name Description
System.String zipFileName

The zip file to extract from.

System.String targetDirectory

The directory to save extracted information in.

FastZip.Overwrite overwrite

The style of overwriting to apply.

FastZip.ConfirmOverwriteDelegate confirmDelegate

A delegate to invoke when confirming overwriting.

System.String fileFilter

A filter to apply to files.

System.String directoryFilter

A filter to apply to directories.

System.Boolean restoreDateTime

Flag indicating whether to restore the date and time for extracted files.

System.Boolean allowParentTraversal

Allow parent directory traversal in file paths (e.g. ../file)

| Improve this Doc View Source

ExtractZip(String, String, String)

Extract the contents of a zip file.

Declaration
public void ExtractZip(string zipFileName, string targetDirectory, string fileFilter)
Parameters
Type Name Description
System.String zipFileName

The zip file to extract from.

System.String targetDirectory

The directory to save extracted information in.

System.String fileFilter

A filter to apply to files.

  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2000-2022 SharpZipLib Contributors