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

  • SEARCH
  • Home
  • 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 6769323
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:10:49+00:00 2026-05-26T15:10:49+00:00

I used many existing codes and I tried to zip the folder in many

  • 0

I used many existing codes and I tried to zip the folder in many ways but still I am having problem with time and folder size (still approx same size).
this code is from the source of the library and still not giving the wanted result

static void Main(string[] args)
{
    //copyDirectory(@"C:\x", @"D:\1");
    ZipOutputStream zip = new ZipOutputStream(File.Create(@"d:\2.zip"));

    zip.SetLevel(9);

    string folder = @"D:\music";

    ZipFolder(folder, folder, zip);
    zip.Finish();
    zip.Close();
}

public static void ZipFolder(string RootFolder, string CurrentFolder, ZipOutputStream zStream)
{
    string[] SubFolders = Directory.GetDirectories(CurrentFolder);

    foreach (string Folder in SubFolders)
        ZipFolder(RootFolder, Folder, zStream);

    string relativePath = CurrentFolder.Substring(RootFolder.Length) + "/";

    if (relativePath.Length > 1)
    {
        ZipEntry dirEntry;

        dirEntry = new ZipEntry(relativePath);
        dirEntry.DateTime = DateTime.Now;
    }

    foreach (string file in Directory.GetFiles(CurrentFolder))
    {
        AddFileToZip(zStream, relativePath, file);
    }
}

private static void AddFileToZip(ZipOutputStream zStream, string relativePath, string file)
{
    byte[] buffer = new byte[4096];
    string fileRelativePath = (relativePath.Length > 1 ? relativePath : string.Empty) + Path.GetFileName(file);
    ZipEntry entry = new ZipEntry(fileRelativePath);

    entry.DateTime = DateTime.Now;
    zStream.PutNextEntry(entry);

    using (FileStream fs = File.OpenRead(file))
    {
        int sourceBytes;

        do
        {
            sourceBytes = fs.Read(buffer, 0, buffer.Length);
            zStream.Write(buffer, 0, sourceBytes);
        } while (sourceBytes > 0);
    }
}
  • 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-26T15:10:49+00:00Added an answer on May 26, 2026 at 3:10 pm

    string folder = @”D:\music”;

    If you’re trying to zip MP3 files you’re not going to see much shrinking.

    There are limits to how much a compression algorithm can do anyway. And more compression always takes more time.

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

Sidebar

Related Questions

I have used many of the Convert.To..... functions for conversion , but I didn't
I've been working on this problem for a few hours and have used many
I used many different browsers while I was coding for a new site (Firefox,
I have not used many lambda expressions before and I ran into a case
I want to create a template for a component that is used many times
How can I set an image for UITableViewController ? I have used many things
std::swap() is used by many std containers (such as std::list and std::vector ) during
I like the effect used in many iPhone apps where a semi-transparent help screen
I have a servlet that is used for many different actions, used in the
I have a few webservices (.net 2.0/ C#) used by many partners. One of

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.