Export (0) Print
Expand All

ZipArchive.CreateEntry Method (String)

.NET Framework 4.5

Creates an empty entry that has the specified path and entry name in the zip archive.

Namespace:  System.IO.Compression
Assembly:  System.IO.Compression (in System.IO.Compression.dll)

member CreateEntry : 
        entryName:string -> ZipArchiveEntry


Type: System.String

A path, relative to the root of the archive, that specifies the name of the entry to be created.

Return Value

Type: System.IO.Compression.ZipArchiveEntry
An empty entry in the zip archive.


entryName is Empty.


entryName is a null reference (Nothing in Visual Basic).


The zip archive does not support writing.


The zip archive has been disposed.

The entryName string should reflect the relative path of the entry you want to create within the zip archive. There is no restriction on the string you provide. However, if it is not formatted as a relative path, the entry is created, but you may get an exception when you extract the contents of the zip archive. If an entry with the specified path and name already exists in the archive, a second entry is created with the same path and name.

The value of the LastWriteTime property for the new entry is set to the current time. The entry is compressed using the default compression level of the underlying compression algorithm. If you want to specify a different compression level, use the CreateEntry method.

The following example shows how to create an entry and write to it by using a stream.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5

.NET for Windows Store apps

Supported in: Windows 8

.NET for Windows Phone apps

Supported in: Windows Phone 8.1

Windows Phone 8.1, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

© 2014 Microsoft