Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Your fly down? Zip it up natively.

zipper Jaime Olivares got sick and tired of having to use the java.util.zip namespace or invoking shell API's to produce a Zip file.  Jaime decided to create a pure .Net 3.0 / 3.5 class that can create / append to zip file.

Here is a quick example on how he zips a file.

ZipStorer zip;

if (this.RadioCreate.Checked)
    // Creates a new zip file
    zip = ZipStorer.Create(TextStorage.Text, "Generated by ZipStorer class");
    // Creates a new zip file
    zip = ZipStorer.Open(TextStorage.Text, FileAccess.Write);

// Stores all the files into the zip file
foreach (string path in listBox1.Items)
    zip.AddFile(path, Path.GetFileName(path), "");

// Creates a memory stream with text
MemoryStream readme = new MemoryStream(
System.Text.Encoding.UTF8.GetBytes(string.Format("{0}\r\nThis file
    has been {1} using the ZipStorer class, by Jaime Olivares.",
DateTime.Now, this.RadioCreate.Checked ? "created" : "appended")));

// Stores a new file directly from the stream
zip.AddStream("readme.txt", readme, DateTime.Now, "Please read");

// Updates and closes the zip file

Another awesome thing is you can use this class with the .Net Compact Framework.


Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation

Remove this comment

Remove this thread


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.