Ionic Zip Library v1.9.1.6
AddEntry Method (entryName, content)
Adds a named entry into the zip archive, taking content for the entry
from a string.
Declaration Syntax
Return Value
The ZipEntry added.
Remarks
Calling this method creates an entry using the given fileName and
directory path within the archive. There is no need for a file by the
given name to exist in the filesystem; the name is used within the zip
archive only. The content for the entry is encoded using the default text
encoding for the machine, or on Silverlight, using UTF-8.
Examples
This example shows how to add an entry to the zipfile, using a string as
content for that entry.
CopyC#
string Content = "This string will be the content of the Readme.txt file in the zip archive."; using (ZipFile zip1 = new ZipFile()) { zip1.AddFile("MyDocuments\\Resume.doc", "files"); zip1.AddEntry("Readme.txt", Content); zip1.Comment = "This zip file was created at " + System.DateTime.Now.ToString("G"); zip1.Save("Content.zip"); }
CopyVB.NET
Public Sub Run() Dim Content As String = "This string will be the content of the Readme.txt file in the zip archive." Using zip1 As ZipFile = New ZipFile zip1.AddEntry("Readme.txt", Content) zip1.AddFile("MyDocuments\Resume.doc", "files") zip1.Comment = ("This zip file was created at " & DateTime.Now.ToString("G")) zip1.Save("Content.zip") End Using End Sub