Delegate WriteDelegate¶
Namespace: OfficeOpenXml.Packaging.Ionic.Zip
Assembly: EPPlus.dll
Delegate in which the application writes the ZipEntry content for the named entry.
Parameters¶
entryName string
The name of the entry that must be written.
stream Stream
The stream to which the entry data should be written.
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.
See Also¶
ZipFile.AddEntry\([string](https://learn.microsoft.com/dotnet/api/system.string), [WriteDelegate](OfficeOpenXml.Packaging.Ionic.Zip.WriteDelegate.md)\)