Method | Description | |
---|---|---|
AddDirectory ( string directoryName ) : |
Adds the contents of a filesystem directory to a Zip file archive. The name of the directory may be a relative path or a fully-qualified path. Any files within the named directory are added to the archive. Any subdirectories within the named directory are also added to the archive, recursively. Top-level entries in the named directory will appear as top-level entries in the zip archive. Entries in subdirectories in the named directory will result in entries in subdirectories in the zip archive. If you want the entries to appear in a containing directory in the zip archive itself, then you should call the AddDirectory() overload that allows you to explicitly specify a directory path for use in the archive. For |
|
AddDirectory ( string directoryName, string directoryPathInArchive ) : |
Adds the contents of a filesystem directory to a Zip file archive, overriding the path to be used for entries in the archive. The name of the directory may be a relative path or a fully-qualified path. The add operation is recursive, so that any files or subdirectories within the name directory are also added to the archive. Top-level entries in the named directory will appear as top-level entries in the zip archive. Entries in subdirectories in the named directory will result in entries in subdirectories in the zip archive. For |
|
AddDirectoryByName ( string directoryNameInArchive ) : |
Creates a directory in the zip archive. Use this when you want to create a directory in the archive but there is no corresponding filesystem representation for that directory. You will probably not need to do this in your code. One of the only times you will want to do this is if you want an empty directory in the zip archive. The reason: if you add a file to a zip archive that is stored within a multi-level directory, all of the directory tree is implicitly created in the zip archive. |
|
AddEntry ( string entryName, OpenDelegate opener, CloseDelegate closer ) : |
Add an entry, for which the application will provide a stream containing the entry data, on a just-in-time basis. In cases where the application wishes to open the stream that holds the content for the ZipEntry, on a just-in-time basis, the application can use this method. The application provides an opener delegate that will be called by the DotNetZip library to obtain a readable stream that can be read to get the bytes for the given entry. Typically, this delegate opens a stream. Optionally, the application can provide a closer delegate as well, which will be called by DotNetZip when all bytes have been read from the entry. These delegates are called from within the scope of the call to ZipFile.Save(). For |
|
AddEntry ( string entryName, Stream stream ) : |
Create an entry in the The application should provide an open, readable stream; in this case it will be read during the call to ZipFile.Save() or one of its overloads. The passed stream will be read from its current position. If necessary, callers should set the position in the stream before calling AddEntry(). This might be appropriate when using this method with a MemoryStream, for example. In cases where a large number of streams will be added to the For |
|
AddEntry ( string entryName, WriteDelegate writer ) : |
Add a ZipEntry for which content is written directly by the application. When the application needs to write the zip entry data, use this method to add the ZipEntry. For example, in the case that the application wishes to write the XML representation of a DataSet into a ZipEntry, the application can use this method to do so. For About progress events: When using the WriteDelegate, DotNetZip does not issue any SaveProgress events with Note: When you use PKZip encryption, it's normally necessary to compute the CRC of the content to be encrypted, before compressing or encrypting it. Therefore, when using PKZip encryption with a WriteDelegate, the WriteDelegate CAN BE called twice: once to compute the CRC, and the second time to potentially compress and encrypt. Surprising, but true. This is because PKWARE specified that the encryption initialization data depends on the CRC. If this happens, for each call of the delegate, your application must stream the same entry data in its entirety. If your application writes different data during the second call, it will result in a corrupt zip file. The double-read behavior happens with all types of entries, not only those that use WriteDelegate. It happens if you add an entry from a filesystem file, or using a string, or a stream, or an opener/closer pair. But in those cases, DotNetZip takes care of reading twice; in the case of the WriteDelegate, the application code gets invoked twice. Be aware. As you can imagine, this can cause performance problems for large streams, and it can lead to correctness problems when you use a In the future I may modify DotNetZip to *always* use bit 3 when PKZIP encryption is in use. This seems like a win overall, but there will be some work involved. If you feel strongly about it, visit the DotNetZip forums and vote up |
|
AddEntry ( string entryName, byte byteContent ) : |
Add an entry into the zip archive using the given filename and directory path within the archive, and the given content for the file. No file is created in the filesystem.
|
|
AddEntry ( string entryName, string content ) : |
Adds a named entry into the zip archive, taking content for the entry from a string. Calling this method creates an entry using the given fileName and directory path within the archive. There is no need for a file by the given name to exist in the filesystem; the name is used within the zip archive only. The content for the entry is encoded using the default text encoding for the machine, or on Silverlight, using UTF-8. |
|
AddEntry ( string entryName, string content, System encoding ) : |
Adds a named entry into the zip archive, taking content for the entry from a string, and using the specified text encoding. Calling this method creates an entry using the given fileName and directory path within the archive. There is no need for a file by the given name to exist in the filesystem; the name is used within the zip archive only. The content for the entry, a string value, is encoded using the given text encoding. A BOM (byte-order-mark) is emitted into the file, if the Encoding parameter is set for that. Most Encoding classes support a constructor that accepts a boolean, indicating whether to emit a BOM or not. For example see |
|
AddFile ( string fileName ) : |
Adds a File to a Zip file archive. This call collects metadata for the named file in the filesystem, including the file attributes and the timestamp, and inserts that metadata into the resulting ZipEntry. Only when the application calls Save() on the This method will throw an exception if an entry with the same name already exists in the For |
|
AddFile ( string fileName, String directoryPathInArchive ) : |
Adds a File to a Zip file archive, potentially overriding the path to be used within the zip archive. The file added by this call to the This method will throw an exception if an entry with the same name already exists in the This version of the method allows the caller to explicitly specify the directory path to be used in the archive. For |
|
AddFiles ( System |
This method adds a set of files to the Use this method to add a set of files to the zip archive, in one call. For example, a list of files received from For |
|
AddFiles ( System |
Adds a set of files to the Any directory structure that may be present in the filenames contained in the list is "flattened" in the archive. Each file in the list is added to the archive in the specified top-level directory. For |
|
AddFiles ( System |
Adds a set of files to the Think of the directoryPathInArchive as a "root" or base directory used in the archive for the files that get added. when preserveDirHierarchy is true, the hierarchy of files found in the filesystem will be placed, with the hierarchy intact, starting at that root in the archive. When For |
|
AddItem ( String fileOrDirectoryName, String directoryPathInArchive ) : |
Adds an item, either a file or a directory, to a zip file archive, explicitly specifying the directory path to be used in the archive. If adding a directory, the add is recursive on all files and subdirectories contained within it. The name of the item may be a relative path or a fully-qualified path. The item added by this call to the This version of the method allows the caller to explicitly specify the directory path to be used in the archive, which would override the "natural" path of the filesystem file. Encryption will be used on the file data if the For |
|
AddItem ( string fileOrDirectoryName ) : |
Adds an item, either a file or a directory, to a zip file archive. This method is handy if you are adding things to zip archive and don't want to bother distinguishing between directories or files. Any files are added as single entries. A directory added through this method is added recursively: all files and subdirectories contained within the directory are added to the The name of the item may be a relative path or a fully-qualified path. Remember, the items contained in The directory name used for the file within the archive is the same as the directory name (potentially a relative path) specified in the fileOrDirectoryName. For |
|
RemoveEntries ( System |
This method removes a collection of entries from the
|
|
RemoveEntries ( System |
This method removes a collection of entries from the
|
|
Save ( ) : void |
Saves the Zip archive to a file, specified by the Name property of the The The ZipFile.Name property is specified either explicitly, or implicitly using one of the parameterized ZipFile constructors. For COM Automation clients, the When using a filesystem file for the Zip output, it is possible to call Data for entries that have been added to the |
|
Save ( Stream outputStream ) : void |
Save the zip archive to the specified stream. The Use this method to save the zip content to a stream directly. A common scenario is an ASP.NET application that dynamically generates a zip file and allows the browser to download it. The application can call Be careful when saving a file to a non-seekable stream, including |
|
Save ( String fileName ) : void |
Save the file to a new zipfile, with the given name. This method allows the application to explicitly specify the name of the zip file when saving. Use this when creating a new zip file, or when updating a zip archive. An application can also save a zip archive in several places by calling this method multiple times in succession, with different filenames. The |
|
UpdateDirectory ( string directoryName ) : |
Add or update a directory in a zip archive. If the specified directory does not exist in the archive, then this method is equivalent to calling |
|
UpdateDirectory ( string directoryName, String directoryPathInArchive ) : |
Add or update a directory in the zip archive at the specified root directory in the archive. If the specified directory does not exist in the archive, then this method is equivalent to calling |
|
UpdateEntry ( string entryName, OpenDelegate opener, CloseDelegate closer ) : |
Updates the given entry in the Calling this method is equivalent to removing the |
|
UpdateEntry ( string entryName, Stream stream ) : |
Updates the given entry in the Calling the method is equivalent to calling The stream must be open and readable during the call to For |
|
UpdateEntry ( string entryName, WriteDelegate writer ) : |
Updates the given entry in the Calling this method is equivalent to removing the |
|
UpdateEntry ( string entryName, byte byteContent ) : |
Updates the given entry in the Calling this method is equivalent to removing the |
|
UpdateEntry ( string entryName, string content ) : |
Updates the given entry in the Calling this method is equivalent to removing the |
|
UpdateEntry ( string entryName, string content, System encoding ) : |
Updates the given entry in the Calling this method is equivalent to removing the |
|
UpdateFile ( string fileName ) : |
Adds or Updates a File in a Zip file archive. This method adds a file to a zip archive, or, if the file already exists in the zip archive, this method Updates the content of that given filename in the zip archive. The Upon success, there is no way for the application to learn whether the file was added versus updated. For |
|
UpdateFile ( string fileName, String directoryPathInArchive ) : |
Adds or Updates a File in a Zip file archive. This method adds a file to a zip archive, or, if the file already exists in the zip archive, this method Updates the content of that given filename in the zip archive. This version of the method allows the caller to explicitly specify the directory path to be used in the archive. The entry to be added or updated is found by using the specified directory path, combined with the basename of the specified filename. Upon success, there is no way for the application to learn if the file was added versus updated. For |
|
UpdateFiles ( System |
Adds or updates a set of files in the Any files that already exist in the archive are updated. Any files that don't yet exist in the archive are added. For |
|
UpdateFiles ( System |
Adds or updates a set of files to the Any files that already exist in the archive are updated. Any files that don't yet exist in the archive are added. For |
|
UpdateItem ( string itemName ) : void |
Add or update a file or directory in the zip archive. This is useful when the application is not sure or does not care if the item to be added is a file or directory, and does not know or does not care if the item already exists in the For |
|
UpdateItem ( string itemName, string directoryPathInArchive ) : void |
Add or update a file or directory. This method is useful when the application is not sure or does not care if the item to be added is a file or directory, and does not know or does not care if the item already exists in the This version of the method allows the caller to explicitly specify the directory path to be used for the item being added to the archive. The entry or entries that are added or updated will use the specified For |
Method | Description | |
---|---|---|
AddOrUpdateDirectoryImpl ( string directoryName, string rootDirectoryPathInArchive, AddOrUpdateAction action ) : |
||
AddOrUpdateDirectoryImpl ( string directoryName, string rootDirectoryPathInArchive, AddOrUpdateAction action, bool recurse, int level ) : |
||
CleanupAfterSaveOperation ( ) : void | ||
DeleteFileWithRetry ( string filename ) : void |
Delete file with retry on UnauthorizedAccessException. When calling File.Delete() on a file that has been "recently" created, the call sometimes fails with UnauthorizedAccessException. This method simply retries the Delete 3 times with a sleep between tries. |
|
InternalAddEntry ( String name, |
||
NotifyEntriesSaveComplete ( ICollection |
||
RemoveEntryForUpdate ( string entryName ) : void | ||
RemoveTempFile ( ) : void | ||
_InternalAddEntry ( |
public AddDirectory ( string directoryName ) : |
||
directoryName | string | The name of the directory to add. |
return |
public AddDirectory ( string directoryName, string directoryPathInArchive ) : |
||
directoryName | string | The name of the directory to add. |
directoryPathInArchive | string |
/// Specifies a directory path to use to override any path in the
/// DirectoryName. This path may, or may not, correspond to a real directory
/// in the current filesystem. If the zip is later extracted, this is the
/// path used for the extracted file or directory. Passing |
return |
public AddDirectoryByName ( string directoryNameInArchive ) : |
||
directoryNameInArchive | string | /// The name of the directory to create in the archive. /// |
return |
public AddEntry ( string entryName, OpenDelegate opener, CloseDelegate closer ) : |
||
entryName | string | the name of the entry to add |
opener | OpenDelegate | /// the delegate that will be invoked by ZipFile.Save() to get the /// readable stream for the given entry. ZipFile.Save() will call /// read on this stream to obtain the data for the entry. This data /// will then be compressed and written to the newly created zip /// file. /// |
closer | CloseDelegate | /// the delegate that will be invoked to close the stream. This may /// be null (Nothing in VB), in which case no call is makde to close /// the stream. /// |
return |
public AddEntry ( string entryName, Stream stream ) : |
||
entryName | string | /// The name, including any path, which is shown in the zip file for the added /// entry. /// |
stream | Stream | /// The input stream from which to grab content for the file /// |
return |
public AddEntry ( string entryName, WriteDelegate writer ) : |
||
entryName | string | the name of the entry to add |
writer | WriteDelegate | the delegate which will write the entry content |
return |
public AddEntry ( string entryName, byte byteContent ) : |
||
entryName | string | /// The name, including any path, to use within the archive for the entry. /// |
byteContent | byte | The data to use for the entry. |
return |
public AddEntry ( string entryName, string content ) : |
||
entryName | string | /// The name, including any path, to use for the entry within the archive. /// |
content | string | /// The content of the file, should it be extracted from the zip. /// |
return |
public AddEntry ( string entryName, string content, System encoding ) : |
||
entryName | string | /// The name, including any path, to use within the archive for the entry. /// |
content | string | /// The content of the file, should it be extracted from the zip. /// |
encoding | System |
/// The text encoding to use when encoding the string. Be aware: This is
/// distinct from the text encoding used to encode the fileName, as specified
/// in |
return |
public AddFile ( string fileName ) : |
||
fileName | string | /// The name of the file to add. It should refer to a file in the filesystem. /// The name of the file may be a relative path or a fully-qualified path. /// |
return |
public AddFile ( string fileName, String directoryPathInArchive ) : |
||
fileName | string | /// The name of the file to add. The name of the file may be a relative path /// or a fully-qualified path. /// |
directoryPathInArchive | String |
/// Specifies a directory path to use to override any path in the fileName.
/// This path may, or may not, correspond to a real directory in the current
/// filesystem. If the files within the zip are later extracted, this is the
/// path used for the extracted file. Passing |
return |
public AddFiles ( System |
||
fileNames | System |
/// The collection of names of the files to add. Each string should refer to a /// file in the filesystem. The name of the file may be a relative path or a /// fully-qualified path. /// |
return | void |
public AddFiles ( System |
||
fileNames | System |
/// The names of the files to add. Each string should refer to /// a file in the filesystem. The name of the file may be a /// relative path or a fully-qualified path. /// |
directoryPathInArchive | String |
/// Specifies a directory path to use to override any path in the file name.
/// Th is path may, or may not, correspond to a real directory in the current
/// filesystem. If the files within the zip are later extracted, this is the
/// path used for the extracted file. Passing |
return | void |
public AddFiles ( System |
||
fileNames | System |
/// The names of the files to add. Each string should refer to a file in the /// filesystem. The name of the file may be a relative path or a /// fully-qualified path. /// |
preserveDirHierarchy | bool |
/// whether the entries in the zip archive will reflect the directory
/// hierarchy that is present in the various filenames. For example, if
/// |
directoryPathInArchive | String |
/// Specifies a directory path to use as a prefix for each entry name.
/// This path may, or may not, correspond to a real directory in the current
/// filesystem. If the files within the zip are later extracted, this is the
/// path used for the extracted file. Passing |
return | void |
public AddItem ( String fileOrDirectoryName, String directoryPathInArchive ) : |
||
fileOrDirectoryName | String | the name of the file or directory to add. /// |
directoryPathInArchive | String |
/// The name of the directory path to use within the zip archive. This path
/// need not refer to an extant directory in the current filesystem. If the
/// files within the zip are later extracted, this is the path used for the
/// extracted file. Passing |
return |
public AddItem ( string fileOrDirectoryName ) : |
||
fileOrDirectoryName | string | /// the name of the file or directory to add. |
return |
public RemoveEntries ( System |
||
entriesToRemove | System |
/// A collection of strings that refer to names of entries to be removed
/// from the |
return | void |
public RemoveEntries ( System |
||
entriesToRemove | System |
/// A collection of ZipEntry instances from this zip file to be removed. For /// example, you can pass in an array of ZipEntry instances; or you can call /// SelectEntries(), and then add or remove entries from that /// ICollection<ZipEntry> (ICollection(Of ZipEntry) in VB), and pass /// that ICollection to this method. /// |
return | void |
public Save ( Stream outputStream ) : void | ||
outputStream | Stream |
/// The |
return | void |
public Save ( String fileName ) : void | ||
fileName | String | /// The name of the zip archive to save to. Existing files will /// be overwritten with great prejudice. /// |
return | void |
public UpdateDirectory ( string directoryName ) : |
||
directoryName | string | /// The path to the directory to be added to the zip archive, or updated in /// the zip archive. /// |
return |
public UpdateDirectory ( string directoryName, String directoryPathInArchive ) : |
||
directoryName | string | /// The path to the directory to be added to the zip archive, or updated /// in the zip archive. /// |
directoryPathInArchive | String |
/// Specifies a directory path to use to override any path in the
/// |
return |
public UpdateEntry ( string entryName, OpenDelegate opener, CloseDelegate closer ) : |
||
entryName | string | /// The name, including any path, to use within the archive for the entry. /// |
opener | OpenDelegate | /// the delegate that will be invoked to open the stream /// |
closer | CloseDelegate | /// the delegate that will be invoked to close the stream /// |
return |
public UpdateEntry ( string entryName, Stream stream ) : |
||
entryName | string | /// The name, including any path, to use within the archive for the entry. /// |
stream | Stream | The input stream from which to read file data. |
return |
public UpdateEntry ( string entryName, WriteDelegate writer ) : |
||
entryName | string | /// The name, including any path, to use within the archive for the entry. /// |
writer | WriteDelegate | the delegate which will write the entry content. |
return |
public UpdateEntry ( string entryName, byte byteContent ) : |
||
entryName | string | /// The name, including any path, to use within the archive for the entry. /// |
byteContent | byte | The content to use for the |
return |
public UpdateEntry ( string entryName, string content ) : |
||
entryName | string | /// The name, including any path, to use within the archive for the entry. /// |
content | string | /// The content of the file, should it be extracted from the zip. /// |
return |
public UpdateEntry ( string entryName, string content, System encoding ) : |
||
entryName | string | /// The name, including any path, to use within the archive for the entry. /// |
content | string | /// The content of the file, should it be extracted from the zip. /// |
encoding | System |
/// The text encoding to use when encoding the string. Be aware: This is
/// distinct from the text encoding used to encode the filename. See |
return |
public UpdateFile ( string fileName ) : |
||
fileName | string | /// The name of the file to add or update. It should refer to a file in the /// filesystem. The name of the file may be a relative path or a /// fully-qualified path. /// |
return |
public UpdateFile ( string fileName, String directoryPathInArchive ) : |
||
fileName | string | /// The name of the file to add or update. It should refer to a file in the /// filesystem. The name of the file may be a relative path or a /// fully-qualified path. /// |
directoryPathInArchive | String |
/// Specifies a directory path to use to override any path in the
/// |
return |
public UpdateFiles ( System |
||
fileNames | System |
/// The collection of names of the files to update. Each string should refer to a file in /// the filesystem. The name of the file may be a relative path or a fully-qualified path. /// |
return | void |
public UpdateFiles ( System |
||
fileNames | System |
/// The names of the files to add or update. Each string should refer to a /// file in the filesystem. The name of the file may be a relative path or a /// fully-qualified path. /// |
directoryPathInArchive | String |
/// Specifies a directory path to use to override any path in the file name.
/// This path may, or may not, correspond to a real directory in the current
/// filesystem. If the files within the zip are later extracted, this is the
/// path used for the extracted file. Passing |
return | void |
public UpdateItem ( string itemName ) : void | ||
itemName | string | /// the path to the file or directory to be added or updated. /// |
return | void |
public UpdateItem ( string itemName, string directoryPathInArchive ) : void | ||
itemName | string | /// The path for the File or Directory to be added or updated. /// |
directoryPathInArchive | string |
/// Specifies a directory path to use to override any path in the
/// |
return | void |