This project is read-only.

C# .NET How can I add individual items one by one to a .zip file using DotNetZip?

Dec 19, 2016 at 12:12 AM
I'm trying to rewrite a C# .NET WinForms app that uses FileStream and BinaryWriter to write individual items to a binary file and FileStream and BinaryReader to read them from that binary file. Now I'm thinking about using DoNetZip to write the items to a .zip file instead.

Here's how I wrote them with FileStream/BinaryWriter:
    private void WriteToBinary(string filepath)
    {
        FileStream fs = new FileStream(filepath, FileMode.Create, FileAccess.Write);
        BinaryWriter bw = new BinaryWriter(fs);

        bw.Write(SomeString);
        bw.Write(SomeInteger);
        bw.Write(SomeBoolean);
        bw.Write.(SomeJPGImageInBase64String();
        bw.Write(SomeMP3InBase64);

        fs.Close();
        bw.Close();
    }

Now here's what I'd like to do:
    private void ZipItAll(string filepath)
    {
        Create a new instance of Ionic.Zip or some other zip method;
        Add SomeString to it;
        Add SomeInteger to it;
        Add SomeBoolean to it;
        Add SomeJPGImageInBase64String to it;
        Add SomeMP3InBase64String to it;
        Write the whole thing to a .zip file;
        Call it a day;
    }
Does DotNetZip have functionality to support the step-by-step outlined in ZipItAll()? I want to add individual items one by one and then save the whole thing to a .zip file. The only code examples I can find are where whole files are added one by one instead of individual items.