[]
Used for creating, opening, and managing zip files.
public class C1ZipFile : IDisposable
Use the Open(Stream) or Create(Stream) methods to associate the C1Zip file object with a zip file on disk. Then use the Entries property to add, remove, retrieve, or inspect individual entries in the zip file.
C1ZipFile can only be used with standard zip files. The component does not support other similar formats such as gzip, zip2, tar, or rar.
The standard zip file imposes some limitations on the size of each entry. You cannot use it to compress files larger than 4 gigabytes (uint.MaxValue).
The code below creates a zip file called sources.zip and adds all files with a "cs" extension to the zip file:
// get path for zip file and files to compress
string path = Application.ExecutablePath;
int pos = path.IndexOf(@"\bin");
path = path.Substring(0, pos + 1);
// create a zip file
C1ZipFile zip = new C1ZipFile();
zip.Create(path + "source.zip");
// add all files with extension cs to the zip file
foreach (string fileName in Directory.GetFiles(path, "*.cs"))
zip.Entries.Add(fileName);
// show result
foreach (C1ZipEntry ze in zip.Entries)
{
Console.WriteLine("{0} {1:#,##0} {2:#,##0}",
ze.FileName, ze.SizeUncompressed, ze.SizeCompressed);
}
Name | Description |
---|---|
C1ZipFile() | Initializes a new instance of the C1ZipFile class. |
C1ZipFile(Stream) | Initializes a new instance of the C1ZipFile class and opens a zip stream associated with this new instance. |
C1ZipFile(Stream, bool) | Initializes a new instance of the C1ZipFile class and opens a zip stream associated with this new instance. |
C1ZipFile(string) | Initializes a new instance of the C1ZipFile class and opens a zip file associated with this new instance. |
C1ZipFile(string, bool) | Initializes a new instance of the C1ZipFile class and creates or opens a zip file associated with this new instance. |
Name | Description |
---|---|
Comment | Gets or sets a comment associated with the current zip file. |
CompressionLevel | Gets or sets the compression level to use when adding entries to the zip file. |
Entries | Gets a C1ZipEntryCollection that contains the entries in the zip file. |
FileName | Gets the name of the current zip file. |
MemoryThreshold | Gets or sets the size of the largest stream to be compressed in memory. |
OverwriteHidden | Determines whether the component should overwrite hidden files when extracting entries from the zip file. |
OverwriteReadOnly | Determines whether the component should overwrite read-only files when extracting entries from the zip file. |
OverwriteSystem | Determines whether the component should overwrite system files when extracting entries from the zip file. |
Password | Gets or sets the password to use when adding or retrieving entries from the zip file. |
TempFileName | Gets or sets the name of the temporary file to use when adding entries to the zip file. |
UseUtf8Encoding | Determines whether file names and comments should be stored in UTF8 format. |
Name | Description |
---|---|
Close() | Resets all data members of the C1ZipFile object. |
CloseBatch() | Closes a zip file after it was opened with a call to the OpenBatch() method. |
Create(Stream) | Creates a new zip file in a stream. |
Create(string) | Creates an empty zip file on disk. |
CreateAsync(Stream) | Asynchronous creates a new zip file in a stream. |
IsZipFile(Stream) | Tests whether a stream contains a valid zip file. |
IsZipFile(string) | Tests whether a file is a valid zip file. |
Open(Stream) | Opens an existing zip file stored in a Stream. |
Open(string) | Opens an existing zip file. |
OpenAsync(Stream) | Asynchronous opens an existing zip file stored in a Stream. |
OpenBatch() | Opens the zip file for multiple operations. |
Refresh() | Refreshes all data members by re-opening the current zip file. |
Name | Description |
---|---|
Progress | Fired while data is being read from or written into a zip file. |