# C1.Zip.C1ZipFile.Create

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_Zip_C1ZipFile_Create_" data-uid="C1.Zip.C1ZipFile.Create*">Create Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_Zip_C1ZipFile_Create_" data-uid="C1.Zip.C1ZipFile.Create*"></a>
<h4 id="C1_Zip_C1ZipFile_Create_System_String_" data-uid="C1.Zip.C1ZipFile.Create(System.String)">Create(string)</h4>
<div class="markdown level1 summary"><p>Creates an empty zip file on disk.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Create(string fileName)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Create(fileName As String)</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>The name of the zip file to create, including the path.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Zip_C1ZipFile_Create_System_String__remarks">Remarks</h5>
<div class="markdown level1 remarks"><p>If a file by the same name already exists, it is deleted before the new one
is created.</p>
</div>


<a id="C1_Zip_C1ZipFile_Create_" data-uid="C1.Zip.C1ZipFile.Create*"></a>
<h4 id="C1_Zip_C1ZipFile_Create_System_IO_Stream_" data-uid="C1.Zip.C1ZipFile.Create(System.IO.Stream)">Create(Stream)</h4>
<div class="markdown level1 summary"><p>Creates a new zip file in a stream.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Create(Stream stream)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Create(stream As Stream)</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><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.io.stream">Stream</a> that will contain the new zip file.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 id="C1_Zip_C1ZipFile_Create_System_IO_Stream__examples">Examples</h5>
<p>The code below creates a new <a class="xref" href="C1.Zip.C1ZipFile.html">C1ZipFile</a> on a memory stream, then adds
several files to it. Finally, the code gets the zipped data out as an array of bytes,
which could be stored in a database for example.</p>
<pre><code class="lang-csharp">// create zip on a stream
MemoryStream msZip = new MemoryStream();
C1ZipFile zip = new C1ZipFile(msZip, true);

// add some entries to it
foreach (string f in Directory.GetFiles(@"c:\WINDOWS\Web\Wallpaper"))
{
  zip.Entries.Add(f);
}

// get zipped data out as a byte array
byte[] zipData = msZip.ToArray();</code></pre>

</div>
