AddEntry Method (entryName, content)

DotNetZip

Ionic Zip Library v1.9.1.6 AddEntry Method (entryName, content)
ReferenceIonic.ZipZipFileAddEntry(String, String)
Adds a named entry into the zip archive, taking content for the entry from a string.
Declaration Syntax
C# Visual Basic Visual C++
public ZipEntry AddEntry(
	string entryName,
	string content
)
Public Function AddEntry ( _
	entryName As String, _
	content As String _
) As ZipEntry
public:
ZipEntry^ AddEntry(
	String^ entryName, 
	String^ content
)
Parameters
entryName (String)
The name, including any path, to use for the entry within the archive.
content (String)
The content of the file, should it be extracted from the zip.
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

Assembly: Ionic.Zip (Module: Ionic.Zip) Version: 1.9.1.8 (1.9.1.8)