C# ZipArchive CreateEntry(String)
Description
ZipArchive CreateEntry(String)
Creates an empty entry
that has the specified path and entry name in the zip archive.
Syntax
ZipArchive.CreateEntry(String)
has the following syntax.
public ZipArchiveEntry CreateEntry(
string entryName
)
Parameters
ZipArchive.CreateEntry(String)
has the following parameters.
entryName
- A path, relative to the root of the archive, that specifies the name of the entry to be created.
Returns
ZipArchive.CreateEntry(String)
method returns An empty entry in the zip archive.
Example
The following example shows how to create an entry and write to it by using a stream.
//from w w w . j av a 2 s . co m
using System;
using System.IO;
using System.IO.Compression;
class Program
{
static void Main(string[] args)
{
using (FileStream zipToOpen = new FileStream(@"c:\users\exampleuser\release.zip", FileMode.Open))
{
using (ZipArchive archive = new ZipArchive(zipToOpen, ZipArchiveMode.Update))
{
ZipArchiveEntry readmeEntry = archive.CreateEntry("Readme.txt");
using (StreamWriter writer = new StreamWriter(readmeEntry.Open()))
{
writer.WriteLine("Information about this package.");
}
}
}
}
}