ArchiveCreateEntry Method (String, String, Boolean, ArchiveEntrySettings)

Create single entry within the archive.

Namespace:  Aspose.Zip
Assembly:  Aspose.Zip (in Aspose.Zip.dll) Version: 22.3
public ArchiveEntry CreateEntry(
	string name,
	string path,
	bool openImmediately = false,
	ArchiveEntrySettings newEntrySettings = null


Type: SystemString
The name of the entry.
Type: SystemString
The fully qualified name of the new file, or the relative file name to be compressed.
openImmediately (Optional)
Type: SystemBoolean
True if open the file immediately, otherwise open the file on archive saving.
newEntrySettings (Optional)
Type: Aspose.Zip.SavingArchiveEntrySettings
Compression and encryption settings used for added ArchiveEntry item.

Return Value

Type: ArchiveEntry
Zip entry instance.
ArgumentNullExceptionpath is null.
SecurityExceptionThe caller does not have the required permission to access
ArgumentExceptionThe path is empty, contains only white spaces, or contains invalid characters.
UnauthorizedAccessExceptionAccess to file path is denied.
PathTooLongException The specified path, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
NotSupportedExceptionFile at path contains a colon (:) in the middle of the string.

The entry name is solely set within name parameter. The file name provided in path parameter does not affect the entry name.

If the file is opened immediately with openImmediately parameter it becomes blocked until archive is saved.

using (FileStream zipFile = File.Open("", FileMode.Create))
    using (var archive = new Archive())
        archive.CreateEntry("data.bin", "file.dat");
See Also