Saving a String Variable to a Zip File

To save a string variable to a zip file, use one of the following methods:

      C1ZipEntryCollection.OpenWriter method

Use the OpenWriter method to get a stream writer, write the string into it, and then close it. The data is compressed as you write it into the stream, and the whole stream is saved into the zip file when you close it.

      MemoryStream method

Use a MemoryStream method; write the data into it, and then add the stream to the zip file. Note that this method requires a little more work than the OpenWriter method, but is still very manageable.

The following code shows both methods. Add the code to the Button_Click event:

      Visual Basic

      C#


Send us comments about this topic.
Copyright © GrapeCity, inc. All rights reserved.