# C1.Zip.C1ZipFile

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="C1_Zip_C1ZipFile" data-uid="C1.Zip.C1ZipFile" class="text-break">C1ZipFile Class
</h1>
  <div class="markdown level0 summary"><p>Used for creating, opening, and managing zip files.</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
    <div class="level1"><span class="xref">C1ZipFile</span></div>
  </div>
  <div class="implements">
    <h5>Implements</h5>
    <div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.idisposable">IDisposable</a></div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="C1.Zip.html">C1.Zip</a></h6>
  <h6><strong>Assembly</strong>: C1.Zip.dll</h6>
  <h5 id="C1_Zip_C1ZipFile_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class C1ZipFile : IDisposable</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public Class C1ZipFile
    Implements IDisposable</code></pre>
  </div>
  <h5 id="C1_Zip_C1ZipFile_remarks"><strong>Remarks</strong></h5>
  <div class="markdown level0 remarks"><p>Use the <a class="xref" href="C1.Zip.C1ZipFile.Open.html#C1_Zip_C1ZipFile_Open_System_IO_Stream_">Open(Stream)</a> or <a class="xref" href="C1.Zip.C1ZipFile.Create.html#C1_Zip_C1ZipFile_Create_System_IO_Stream_">Create(Stream)</a> methods to 
associate the C1Zip file object with a zip file on disk. Then use the 
<a class="xref" href="C1.Zip.C1ZipFile.Entries.html#C1_Zip_C1ZipFile_Entries">Entries</a> property to add, remove, retrieve, or inspect 
individual entries in the zip file.</p>
<p><a class="xref" href="C1.Zip.C1ZipFile.html">C1ZipFile</a> can only be used with standard zip files. The component
does not support other similar formats such as gzip, zip2, tar, or rar.</p>
<p>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).</p>
</div>
  <h5 id="C1_Zip_C1ZipFile_examples"><strong>Examples</strong></h5>
  <p>The code below creates a zip file called <b>sources.zip</b> and adds all
files with a &quot;cs&quot; extension to the zip file:</p>
<pre><code class="lang-csharp">// 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);
}</code></pre>

  <h3 id="constructors">Constructors
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_Zip_C1ZipFile__ctor" data-uid="C1.Zip.C1ZipFile.#ctor">
          <a class="xref" href="C1.Zip.C1ZipFile.-ctor.html#C1_Zip_C1ZipFile__ctor">C1ZipFile()</a>
        </td>
        <td class="markdown level1 summary"><p>Initializes a new instance of the <a class="xref" href="C1.Zip.C1ZipFile.html">C1ZipFile</a> class.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile__ctor_System_IO_Stream_" data-uid="C1.Zip.C1ZipFile.#ctor(System.IO.Stream)">
          <a class="xref" href="C1.Zip.C1ZipFile.-ctor.html#C1_Zip_C1ZipFile__ctor_System_IO_Stream_">C1ZipFile(Stream)</a>
        </td>
        <td class="markdown level1 summary"><p>Initializes a new instance of the <a class="xref" href="C1.Zip.C1ZipFile.html">C1ZipFile</a> class and opens a zip stream associated
with this new instance.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile__ctor_System_IO_Stream_System_Boolean_" data-uid="C1.Zip.C1ZipFile.#ctor(System.IO.Stream,System.Boolean)">
          <a class="xref" href="C1.Zip.C1ZipFile.-ctor.html#C1_Zip_C1ZipFile__ctor_System_IO_Stream_System_Boolean_">C1ZipFile(Stream, bool)</a>
        </td>
        <td class="markdown level1 summary"><p>Initializes a new instance of the <a class="xref" href="C1.Zip.C1ZipFile.html">C1ZipFile</a> class and opens a zip stream associated
with this new instance.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile__ctor_System_String_" data-uid="C1.Zip.C1ZipFile.#ctor(System.String)">
          <a class="xref" href="C1.Zip.C1ZipFile.-ctor.html#C1_Zip_C1ZipFile__ctor_System_String_">C1ZipFile(string)</a>
        </td>
        <td class="markdown level1 summary"><p>Initializes a new instance of the <a class="xref" href="C1.Zip.C1ZipFile.html">C1ZipFile</a> class and opens a zip file associated
with this new instance.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile__ctor_System_String_System_Boolean_" data-uid="C1.Zip.C1ZipFile.#ctor(System.String,System.Boolean)">
          <a class="xref" href="C1.Zip.C1ZipFile.-ctor.html#C1_Zip_C1ZipFile__ctor_System_String_System_Boolean_">C1ZipFile(string, bool)</a>
        </td>
        <td class="markdown level1 summary"><p>Initializes a new instance of the <a class="xref" href="C1.Zip.C1ZipFile.html">C1ZipFile</a> class and creates or opens
a zip file associated with this new instance.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="properties">Properties
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_Zip_C1ZipFile_Comment" data-uid="C1.Zip.C1ZipFile.Comment">
          <a class="xref" href="C1.Zip.C1ZipFile.Comment.html#C1_Zip_C1ZipFile_Comment">Comment</a>
        </td>
        <td class="markdown level1 summary"><p>Gets or sets a comment associated with the current zip file.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_CompressionLevel" data-uid="C1.Zip.C1ZipFile.CompressionLevel">
          <a class="xref" href="C1.Zip.C1ZipFile.CompressionLevel.html#C1_Zip_C1ZipFile_CompressionLevel">CompressionLevel</a>
        </td>
        <td class="markdown level1 summary"><p>Gets or sets the compression level to use when adding entries to the zip file.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_Entries" data-uid="C1.Zip.C1ZipFile.Entries">
          <a class="xref" href="C1.Zip.C1ZipFile.Entries.html#C1_Zip_C1ZipFile_Entries">Entries</a>
        </td>
        <td class="markdown level1 summary"><p>Gets a <a class="xref" href="C1.Zip.C1ZipEntryCollection.html">C1ZipEntryCollection</a> that contains the entries in the zip file.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_FileName" data-uid="C1.Zip.C1ZipFile.FileName">
          <a class="xref" href="C1.Zip.C1ZipFile.FileName.html#C1_Zip_C1ZipFile_FileName">FileName</a>
        </td>
        <td class="markdown level1 summary"><p>Gets the name of the current zip file.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_MemoryThreshold" data-uid="C1.Zip.C1ZipFile.MemoryThreshold">
          <a class="xref" href="C1.Zip.C1ZipFile.MemoryThreshold.html#C1_Zip_C1ZipFile_MemoryThreshold">MemoryThreshold</a>
        </td>
        <td class="markdown level1 summary"><p>Gets or sets the size of the largest stream to be compressed in memory.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_OverwriteHidden" data-uid="C1.Zip.C1ZipFile.OverwriteHidden">
          <a class="xref" href="C1.Zip.C1ZipFile.OverwriteHidden.html#C1_Zip_C1ZipFile_OverwriteHidden">OverwriteHidden</a>
        </td>
        <td class="markdown level1 summary"><p>Determines whether the component should overwrite hidden files when extracting
entries from the zip file.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_OverwriteReadOnly" data-uid="C1.Zip.C1ZipFile.OverwriteReadOnly">
          <a class="xref" href="C1.Zip.C1ZipFile.OverwriteReadOnly.html#C1_Zip_C1ZipFile_OverwriteReadOnly">OverwriteReadOnly</a>
        </td>
        <td class="markdown level1 summary"><p>Determines whether the component should overwrite read-only files when extracting
entries from the zip file.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_OverwriteSystem" data-uid="C1.Zip.C1ZipFile.OverwriteSystem">
          <a class="xref" href="C1.Zip.C1ZipFile.OverwriteSystem.html#C1_Zip_C1ZipFile_OverwriteSystem">OverwriteSystem</a>
        </td>
        <td class="markdown level1 summary"><p>Determines whether the component should overwrite system files when extracting
entries from the zip file.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_Password" data-uid="C1.Zip.C1ZipFile.Password">
          <a class="xref" href="C1.Zip.C1ZipFile.Password.html#C1_Zip_C1ZipFile_Password">Password</a>
        </td>
        <td class="markdown level1 summary"><p>Gets or sets the password to use when adding or retrieving entries from the
zip file.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_TempFileName" data-uid="C1.Zip.C1ZipFile.TempFileName">
          <a class="xref" href="C1.Zip.C1ZipFile.TempFileName.html#C1_Zip_C1ZipFile_TempFileName">TempFileName</a>
        </td>
        <td class="markdown level1 summary"><p>Gets or sets the name of the temporary file to use when adding entries to the zip file.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_UseUtf8Encoding" data-uid="C1.Zip.C1ZipFile.UseUtf8Encoding">
          <a class="xref" href="C1.Zip.C1ZipFile.UseUtf8Encoding.html#C1_Zip_C1ZipFile_UseUtf8Encoding">UseUtf8Encoding</a>
        </td>
        <td class="markdown level1 summary"><p>Determines whether file names and comments should be stored in UTF8 format.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="methods">Methods
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_Zip_C1ZipFile_Close" data-uid="C1.Zip.C1ZipFile.Close">
          <a class="xref" href="C1.Zip.C1ZipFile.Close.html#C1_Zip_C1ZipFile_Close">Close()</a>
        </td>
        <td class="markdown level1 summary"><p>Resets all data members of the <a class="xref" href="C1.Zip.C1ZipFile.html">C1ZipFile</a> object.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_CloseBatch" data-uid="C1.Zip.C1ZipFile.CloseBatch">
          <a class="xref" href="C1.Zip.C1ZipFile.CloseBatch.html#C1_Zip_C1ZipFile_CloseBatch">CloseBatch()</a>
        </td>
        <td class="markdown level1 summary"><p>Closes a zip file after it was opened with a call to the
<a class="xref" href="C1.Zip.C1ZipFile.OpenBatch.html#C1_Zip_C1ZipFile_OpenBatch">OpenBatch()</a> method.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_Create_System_IO_Stream_" data-uid="C1.Zip.C1ZipFile.Create(System.IO.Stream)">
          <a class="xref" href="C1.Zip.C1ZipFile.Create.html#C1_Zip_C1ZipFile_Create_System_IO_Stream_">Create(Stream)</a>
        </td>
        <td class="markdown level1 summary"><p>Creates a new zip file in a stream.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_Create_System_String_" data-uid="C1.Zip.C1ZipFile.Create(System.String)">
          <a class="xref" href="C1.Zip.C1ZipFile.Create.html#C1_Zip_C1ZipFile_Create_System_String_">Create(string)</a>
        </td>
        <td class="markdown level1 summary"><p>Creates an empty zip file on disk.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_CreateAsync_System_IO_Stream_" data-uid="C1.Zip.C1ZipFile.CreateAsync(System.IO.Stream)">
          <a class="xref" href="C1.Zip.C1ZipFile.CreateAsync.html#C1_Zip_C1ZipFile_CreateAsync_System_IO_Stream_">CreateAsync(Stream)</a>
        </td>
        <td class="markdown level1 summary"><p>Asynchronous creates a new zip file in a stream.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_IsZipFile_System_IO_Stream_" data-uid="C1.Zip.C1ZipFile.IsZipFile(System.IO.Stream)">
          <a class="xref" href="C1.Zip.C1ZipFile.IsZipFile.html#C1_Zip_C1ZipFile_IsZipFile_System_IO_Stream_">IsZipFile(Stream)</a>
        </td>
        <td class="markdown level1 summary"><p>Tests whether a stream contains a valid zip file.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_IsZipFile_System_String_" data-uid="C1.Zip.C1ZipFile.IsZipFile(System.String)">
          <a class="xref" href="C1.Zip.C1ZipFile.IsZipFile.html#C1_Zip_C1ZipFile_IsZipFile_System_String_">IsZipFile(string)</a>
        </td>
        <td class="markdown level1 summary"><p>Tests whether a file is a valid zip file.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_Open_System_IO_Stream_" data-uid="C1.Zip.C1ZipFile.Open(System.IO.Stream)">
          <a class="xref" href="C1.Zip.C1ZipFile.Open.html#C1_Zip_C1ZipFile_Open_System_IO_Stream_">Open(Stream)</a>
        </td>
        <td class="markdown level1 summary"><p>Opens an existing zip file stored in a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a>.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_Open_System_String_" data-uid="C1.Zip.C1ZipFile.Open(System.String)">
          <a class="xref" href="C1.Zip.C1ZipFile.Open.html#C1_Zip_C1ZipFile_Open_System_String_">Open(string)</a>
        </td>
        <td class="markdown level1 summary"><p>Opens an existing zip file.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_OpenAsync_System_IO_Stream_" data-uid="C1.Zip.C1ZipFile.OpenAsync(System.IO.Stream)">
          <a class="xref" href="C1.Zip.C1ZipFile.OpenAsync.html#C1_Zip_C1ZipFile_OpenAsync_System_IO_Stream_">OpenAsync(Stream)</a>
        </td>
        <td class="markdown level1 summary"><p>Asynchronous opens an existing zip file stored in a <a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a>.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_OpenBatch" data-uid="C1.Zip.C1ZipFile.OpenBatch">
          <a class="xref" href="C1.Zip.C1ZipFile.OpenBatch.html#C1_Zip_C1ZipFile_OpenBatch">OpenBatch()</a>
        </td>
        <td class="markdown level1 summary"><p>Opens the zip file for multiple operations.</p>
</td>
      </tr>
      <tr>
        <td id="C1_Zip_C1ZipFile_Refresh" data-uid="C1.Zip.C1ZipFile.Refresh">
          <a class="xref" href="C1.Zip.C1ZipFile.Refresh.html#C1_Zip_C1ZipFile_Refresh">Refresh()</a>
        </td>
        <td class="markdown level1 summary"><p>Refreshes all data members by re-opening the current zip file.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="events">Events
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="C1_Zip_C1ZipFile_Progress" data-uid="C1.Zip.C1ZipFile.Progress">
          <a class="xref" href="C1.Zip.C1ZipFile.Progress.html">Progress</a>
        </td>
        <td class="markdown level1 summary"><p>Fired while data is being read from or written into a zip file.</p>
</td>
      </tr>
    </tbody>
  </table>

</div>
