WriteDelegate Delegate

DotNetZip

Ionic Zip Library v1.9.1.6 WriteDelegate Delegate
ReferenceIonic.ZipWriteDelegate
Delegate in which the application writes the ZipEntry content for the named entry.
Declaration Syntax
C# Visual Basic Visual C++
public delegate void WriteDelegate(
	string entryName,
	Stream stream
)
Public Delegate Sub WriteDelegate ( _
	entryName As String, _
	stream As Stream _
)
public delegate void WriteDelegate(
	String^ entryName, 
	Stream^ stream
)
Parameters
entryName (String)
The name of the entry that must be written.
stream (Stream)
The stream to which the entry data should be written.
Remarks
When you add an entry and specify a WriteDelegate, via AddEntry(String, WriteDelegate), the application code provides the logic that writes the entry data directly into the zip file.
Examples
This example shows how to define a WriteDelegate that obtains a DataSet, and then writes the XML for the DataSet into the zip archive. There's no need to save the XML to a disk file first.
CopyC#
private void WriteEntry (String filename, Stream output)
{
    DataSet ds1 = ObtainDataSet();
    ds1.WriteXml(output);
}

private void Run()
{
    using (var zip = new ZipFile())
    {
        zip.AddEntry(zipEntryName, WriteEntry);
        zip.Save(zipFileName);
    }
}
CopyVB.NET
Private Sub WriteEntry (ByVal filename As String, ByVal output As Stream)
    DataSet ds1 = ObtainDataSet()
    ds1.WriteXml(stream)
End Sub

Public Sub Run()
    Using zip = New ZipFile
        zip.AddEntry(zipEntryName, New WriteDelegate(AddressOf WriteEntry))
        zip.Save(zipFileName)
    End Using
End Sub

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