Public Member Functions | |
delegate void | KeysRequiredEventHandler (object sender, KeysRequiredEventArgs e) |
Delegate for handling keys/password setting during compresion/decompression. | |
ZipFile (string name) | |
Opens a Zip file with the given name for reading. | |
ZipFile (FileStream file) | |
Opens a Zip file reading the given FileStream. | |
ZipFile (Stream baseStream) | |
Opens a Zip file reading the given Stream. | |
void | Close () |
Closes the ZipFile. If the stream is IsStreamOwnerowned then this also closes the underlying input stream. Once closed, no further instance methods should be called. | |
IEnumerator | GetEnumerator () |
Returns an enumerator for the Zip entries in this Zip file. | |
int | FindEntry (string name, bool ignoreCase) |
Return the index of the entry with a matching name. | |
ZipEntry | GetEntry (string name) |
Searches for a zip entry in this archive with the given name. String comparisons are case insensitive. | |
bool | TestArchive (bool testData) |
Test an archive for integrity/validity. | |
Stream | GetInputStream (ZipEntry entry) |
Creates an input stream reading the given zip entry as uncompressed data. Normally zip entry should be an entry returned by GetEntry(). | |
Stream | GetInputStream (int entryIndex) |
Creates an input stream reading a zip entry. | |
Public Attributes | |
KeysRequiredEventHandler | KeysRequired |
Event handler for handling encryption keys. | |
Properties | |
byte[] | Key |
Get/set the encryption key value. | |
string | Password |
Password to be used for encrypting/decrypting files. | |
byte[] | iv = null |
bool | HaveKeys |
bool | IsStreamOwner |
Get/set a flag indicating if the underlying stream is owned by the ZipFile instance. If the flag is true then the stream will be closed when CloseClose is called. | |
ZipEntry | this [int index] |
Indexer property for ZipEntries. | |
string | ZipFileComment |
Gets the comment for the zip file. | |
string | Name |
Gets the name of this zip file. | |
int | Size |
Gets the number of entries in this zip file. | |
Private Member Functions | |
void | OnKeysRequired (string fileName) |
Handles getting of encryption keys when required. | |
int | ReadLeShort () |
Read an unsigned short in little endian byte order. | |
int | ReadLeInt () |
Read an int in little endian byte order. | |
long | LocateBlockWithSignature (int signature, long endLocation, int minimumBlockSize, int maximumVariableData) |
void | ReadEntries () |
Search for and read the central directory of a zip file filling the entries array. This is called exactly once by the constructors. | |
long | TestLocalHeader (ZipEntry entry, bool fullTest, bool extractTest) |
Test the local header against that provided from the central directory. | |
long | CheckLocalHeader (ZipEntry entry) |
Checks, if the local header of the entry at index i matches the central directory, and returns the offset to the data. | |
void | ReadFully (Stream s, byte[] outBuf) |
void | CheckClassicPassword (CryptoStream classicCryptoStream, ZipEntry entry) |
Stream | CreateAndInitDecryptionStream (Stream baseStream, ZipEntry entry) |
void | WriteEncryptionHeader (Stream stream, long crcValue) |
Stream | CreateAndInitEncryptionStream (Stream baseStream, ZipEntry entry) |
Stream | GetOutputStream (ZipEntry entry, string fileName) |
Gets an output stream for the specified ZipEntry. | |
Private Attributes | |
string | name |
string | comment |
Stream | baseStream |
bool | isStreamOwner = true |
long | offsetOfFirstEntry = 0 |
ZipEntry[] | entries |
byte[] | key = null |
Classes | |
class | PartialInputStream |
class | ZipEntryEnumeration |
This class is thread safe: You can open input streams for arbitrary entries in different threads.
Author of the original java version : Jochen Hoenicke
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); } } }
Definition at line 139 of file ZipFile.cs.
|
Opens a Zip file with the given name for reading.
Definition at line 221 of file ZipFile.cs. |
|
Opens a Zip file reading the given FileStream.
Definition at line 243 of file ZipFile.cs. |
|
Opens a Zip file reading the given Stream.
Definition at line 266 of file ZipFile.cs. |
|
Definition at line 687 of file ZipFile.cs. References ICSharpCode::SharpZipLib::Zip::ZipEntry::Crc, ICSharpCode::SharpZipLib::Zip::ZipEntry::DosTime, and ICSharpCode::SharpZipLib::Zip::ZipEntry::Flags. |
|
Checks, if the local header of the entry at index i matches the central directory, and returns the offset to the data.
Definition at line 667 of file ZipFile.cs. |
|
Closes the ZipFile. If the stream is IsStreamOwnerowned then this also closes the underlying input stream. Once closed, no further instance methods should be called.
Definition at line 469 of file ZipFile.cs. |
|
|
|
Return the index of the entry with a matching name.
Definition at line 503 of file ZipFile.cs. |
|
Searches for a zip entry in this archive with the given name. String comparisons are case insensitive.
Definition at line 540 of file ZipFile.cs. |
|
Returns an enumerator for the Zip entries in this Zip file.
Definition at line 485 of file ZipFile.cs. |
|
Creates an input stream reading a zip entry.
Definition at line 839 of file ZipFile.cs. |
|
Creates an input stream reading the given zip entry as uncompressed data. Normally zip entry should be an entry returned by GetEntry().
Definition at line 807 of file ZipFile.cs. References ICSharpCode::SharpZipLib::Zip::ZipEntry::Name, and ICSharpCode::SharpZipLib::Zip::ZipEntry::ZipFileIndex. |
|
Gets an output stream for the specified ZipEntry.
Definition at line 765 of file ZipFile.cs. References ICSharpCode::SharpZipLib::Zip::ZipEntry::CompressionMethod, and ICSharpCode::SharpZipLib::Zip::ZipEntry::IsCrypted. |
|
Delegate for handling keys/password setting during compresion/decompression.
|
|
Definition at line 324 of file ZipFile.cs. |
|
Handles getting of encryption keys when required.
Definition at line 167 of file ZipFile.cs. References ICSharpCode::SharpZipLib::Zip::KeysRequiredEventArgs::Key. |
|
Search for and read the central directory of a zip file filling the entries array. This is called exactly once by the constructors.
Definition at line 355 of file ZipFile.cs. |
|
Definition at line 673 of file ZipFile.cs. |
|
Read an int in little endian byte order.
Definition at line 318 of file ZipFile.cs. |
|
Read an unsigned short in little endian byte order.
Definition at line 303 of file ZipFile.cs. |
|
Test an archive for integrity/validity.
Definition at line 554 of file ZipFile.cs. References ICSharpCode::SharpZipLib::Checksums::Crc32::Update(), and ICSharpCode::SharpZipLib::Checksums::Crc32::Value. |
|
Test the local header against that provided from the central directory.
Definition at line 597 of file ZipFile.cs. References ICSharpCode::SharpZipLib::Zip::ZipEntry::CompressionMethod, ICSharpCode::SharpZipLib::Zip::ZipEntry::Crc, ICSharpCode::SharpZipLib::Zip::ZipEntry::Flags, ICSharpCode::SharpZipLib::Zip::ZipEntry::Name, and ICSharpCode::SharpZipLib::Zip::ZipEntry::Offset. |
|
Definition at line 727 of file ZipFile.cs. |
|
Definition at line 143 of file ZipFile.cs. |
|
Definition at line 142 of file ZipFile.cs. |
|
Definition at line 146 of file ZipFile.cs. |
|
Definition at line 144 of file ZipFile.cs. |
|
Definition at line 176 of file ZipFile.cs. |
|
Event handler for handling encryption keys.
Definition at line 161 of file ZipFile.cs. |
|
Definition at line 141 of file ZipFile.cs. |
|
Definition at line 145 of file ZipFile.cs. |
|
Definition at line 207 of file ZipFile.cs. |
|
Get/set a flag indicating if the underlying stream is owned by the ZipFile instance. If the flag is true then the stream will be closed when CloseClose is called. The default value is true in all cases. Definition at line 288 of file ZipFile.cs. |
|
Definition at line 204 of file ZipFile.cs. |
|
Get/set the encryption key value.
Definition at line 182 of file ZipFile.cs. |
|
Gets the name of this zip file.
Definition at line 879 of file ZipFile.cs. |
|
Password to be used for encrypting/decrypting files. Set to null if no password is required. Definition at line 192 of file ZipFile.cs. |
|
Gets the number of entries in this zip file.
Definition at line 891 of file ZipFile.cs. |
|
Indexer property for ZipEntries.
Definition at line 521 of file ZipFile.cs. |
|
Gets the comment for the zip file.
Definition at line 870 of file ZipFile.cs. |