Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6030725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:04:47+00:00 2026-05-23T05:04:47+00:00

From examples, I’ve got a pretty good grasp over how to extract a zip

  • 0

From examples, I’ve got a pretty good grasp over how to extract a zip file.

In nearly every example, the method of identifying when a ZipEntry is a directory is as follows

string directoryName = Path.GetDirectoryName(theEntry.Name);
string fileName = Path.GetFileName(theEntry.Name);

if (directoryName.Length > 0)
  Directory.CreateDirectory(Path.Combine(destinationDirectory, directoryName));                    

if (fileName != String.Empty)
{
  //read data and write to file
}

Now is is fine and all (directory encountered, create it), directory is available when the file is extracted.

I can add files to a zip fine, but how do I add folders? I understand I’ll be looping through the directories, adding the files encountered (and their ZipEntry.Name property is populated properly), but how do I add a ZipEntry to the archive and instruct the ZipOutputStream that it is a directory?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:04:48+00:00Added an answer on May 23, 2026 at 5:04 am

    ZipFile.AddDirectory does what you want. Small sample code here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ive got the following code which I hacked together from website examples. It works
I have `a string example = this site holds all the examples from The
I'm trying out ExtJS Pivot Grid. I'm using the examples pretty much as-is from
From the examples below showing the loading of a DropDownList in ASP.NET which method
Tried examples from 'php.net' but don't understand what's the problem. Any suggestions? <?php $_SESSION['test']
Strange situation - examples from apple works, but after i change them a bit,
I have code examples from some of my previous work that help me to
I took the following code from the examples page on Asio class tcp_connection :
Im trying to hammer togehter a WYSIWYG-edit in c# following some examples from here
I'm looking to create a custom date picker with code examples from several sources.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.