To stream multiple XML files directly into the zip file, use the OpenWriter method. That returns a stream that you can write to, and when the stream is closed it is added to the zip file.
Add the following code to the Click event:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim zip As New C1ZipFile()
zip.Create("c:\temp\test.zip")
Dim s As Stream = zip.Entries.OpenWriter("entry1", True)
Dim sw As New C1ZStreamWriter(s)
sw.WriteLine("Hello world")
' Continue writing as much as you want...
sw.Close()
s = zip.Entries.OpenWriter("entry2", True)
sw = New C1ZStreamWriter(s)
sw.WriteLine("Hello again")
' Continue writing as much as you want...
sw.Close()
End Sub
•C#
private void button1_Click(object sender, System.EventArgs e)
{
C1ZipFile zip = new C1ZipFile();
zip.Create(@"c:\temp\test.zip");
Stream s = zip.Entries.OpenWriter("entry1", true);
C1ZStreamWriter sw = new C1ZStreamWriter(s);
sw.WriteLine("Hello world");
// Continue writing as much as you want...
sw.Close();
s = zip.Entries.OpenWriter("entry2", true);
sw = new C1ZStreamWriter(s);
sw.WriteLine("Hello again");
// Continue writing as much as you want...
sw.Close();
}
To read an entry without saving it to a file, use the OpenReader method on the entry object.
Note: OpenWriter is a member of the C1ZipEntryCollection class, while OpenReader is a member of the C1ZipEntry class.