Delegate WriteDelegate
Delegate in which the application writes the ZipEntry content for the named entry.
public delegate void WriteDelegate(string entryName, Stream stream)
Parameters
entryNamestringThe name of the entry that must be written.
streamStreamThe stream to which the entry data should be written.
- Extension Methods
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.
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);
}
}
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
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.