# C1.Zip.C1ZipEntryCollection.AddAsync

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Zip_C1ZipEntryCollection_AddAsync_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync*">AddAsync Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Zip_C1ZipEntryCollection_AddAsync_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync*"></a>
<h4 id="C1_Zip_C1ZipEntryCollection_AddAsync_System_IO_Stream_System_String_System_DateTime_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync(System.IO.Stream,System.String,System.DateTime)">AddAsync(Stream, string, DateTime)</h4>
<div class="markdown level1 summary"><p>Asynchronous adds a stream to the current zip file.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public Task AddAsync(Stream stream, string entryName, DateTime dateTime)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function AddAsync(stream As Stream, entryName As String, dateTime As Date) As Task</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a></td>
      <td><span class="parametername">stream</span></td>
      <td><p>Stream that contains data for the new entry.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">entryName</span></td>
      <td><p>Name to be used for the new entry.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.datetime">DateTime</a></td>
      <td><span class="parametername">dateTime</span></td>
      <td><p>The date and time when the file was last modified.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
      <td></td>
    </tr>
  </tbody>
</table>


<a id="C1_Zip_C1ZipEntryCollection_AddAsync_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync*"></a>
<h4 id="C1_Zip_C1ZipEntryCollection_AddAsync_System_IO_Stream_System_String_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync(System.IO.Stream,System.String)">AddAsync(Stream, string)</h4>
<div class="markdown level1 summary"><p>Asynchronous adds a stream to the current zip file.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public Task AddAsync(Stream stream, string entryName)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function AddAsync(stream As Stream, entryName As String) As Task</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a></td>
      <td><span class="parametername">stream</span></td>
      <td><p>Stream that contains data for the new entry.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">entryName</span></td>
      <td><p>Name to be used for the new entry.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
      <td></td>
    </tr>
  </tbody>
</table>


<a id="C1_Zip_C1ZipEntryCollection_AddAsync_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync*"></a>
<h4 id="C1_Zip_C1ZipEntryCollection_AddAsync_System_String_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync(System.String)">AddAsync(string)</h4>
<div class="markdown level1 summary"><p>Asynchronous adds an entry to the current zip file.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public Task AddAsync(string fileName)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function AddAsync(fileName As String) As Task</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">fileName</span></td>
      <td><p>Name of the file to add to the zip file.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Zip_C1ZipEntryCollection_AddAsync_System_String__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>By default, the directory name is not stored in the zip file. To store a specific
part of the directory name in the zip file, use the overloaded version of the
<b>Add</b> method with a <b>pathLevels</b> parameter.</p>
</div>
<h5 id="C1_Zip_C1ZipEntryCollection_AddAsync_System_String__examples">Examples</h5>
<p>To create a zip archive use AddAsync(filePath) and AddAsync(stream):</p>



<a id="C1_Zip_C1ZipEntryCollection_AddAsync_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync*"></a>
<h4 id="C1_Zip_C1ZipEntryCollection_AddAsync_System_String___" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync(System.String[])">AddAsync(string[])</h4>
<div class="markdown level1 summary"><p>Adds a list of entries to the current zip file.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public Task AddAsync(string[] fileNames)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function AddAsync(fileNames As String()) As Task</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a>[]</td>
      <td><span class="parametername">fileNames</span></td>
      <td><p>Array containing the file names of the entries to be added to the zip file.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
      <td></td>
    </tr>
  </tbody>
</table>


<a id="C1_Zip_C1ZipEntryCollection_AddAsync_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync*"></a>
<h4 id="C1_Zip_C1ZipEntryCollection_AddAsync_System_String_System_Int32_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync(System.String,System.Int32)">AddAsync(string, int)</h4>
<div class="markdown level1 summary"><p>Asynchronous adds an entry to the current zip file.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public Task AddAsync(string fileName, int pathLevels)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function AddAsync(fileName As String, pathLevels As Integer) As Task</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">fileName</span></td>
      <td><p>Name of the file to add to the zip file.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.int32">int</a></td>
      <td><span class="parametername">pathLevels</span></td>
      <td><p>The number of path levels to be stored as the entry name.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Zip_C1ZipEntryCollection_AddAsync_System_String_System_Int32__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>By default, path names are not stored in the zip file. For example, adding
the file "c:\temp\samples\readme.txt" to the zip file will create an entry called
"readme.txt".</p>
<p>The <code class="paramref">pathLevels</code> parameter allows you to store one or more levels of the path in the entry name.
For example, adding the file "c:\temp\samples\readme.txt" to the zip file with <code class="paramref">pathLevels</code>=1 
will create an entry called "samples\readme.txt".</p>
</div>


<a id="C1_Zip_C1ZipEntryCollection_AddAsync_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync*"></a>
<h4 id="C1_Zip_C1ZipEntryCollection_AddAsync_System_String_System_String_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync(System.String,System.String)">AddAsync(string, string)</h4>
<div class="markdown level1 summary"><p>Asynchronous adds an entry to the current zip file.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public Task AddAsync(string fileName, string entryName)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function AddAsync(fileName As String, entryName As String) As Task</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">fileName</span></td>
      <td><p>Name of the file to add to the zip file.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">entryName</span></td>
      <td><p>Name of the new entry as stored in the zip file.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Zip_C1ZipEntryCollection_AddAsync_System_String_System_String__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>By default, entries in the zip file have the same name as the original (uncompressed)
file. This method allows you to specify a different name, including a path for example.</p>
</div>


<a id="C1_Zip_C1ZipEntryCollection_AddAsync_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync*"></a>
<h4 id="C1_Zip_C1ZipEntryCollection_AddAsync_System_String_System_String_System_DateTime_" data-uid="C1.Zip.C1ZipEntryCollection.AddAsync(System.String,System.String,System.DateTime)">AddAsync(string, string, DateTime)</h4>
<div class="markdown level1 summary"><p>Asynchronous adds an entry to the current zip file.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public Task AddAsync(string fileName, string entryName, DateTime dateTime)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Function AddAsync(fileName As String, entryName As String, dateTime As Date) As Task</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">fileName</span></td>
      <td><p>Name of the file to add to the zip file.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">entryName</span></td>
      <td><p>Name of the new entry as stored in the zip file.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.datetime">DateTime</a></td>
      <td><span class="parametername">dateTime</span></td>
      <td><p>The date and time when the file was last modified.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="returns">Returns</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.threading.tasks.task">Task</a></td>
      <td></td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Zip_C1ZipEntryCollection_AddAsync_System_String_System_String_System_DateTime__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>By default, entries in the zip file have the same name as the original (uncompressed)
file. This method allows you to specify a different name, including a path for example.</p>
</div>
</div>
