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 7595411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T21:40:00+00:00 2026-05-30T21:40:00+00:00

I have a method that zips up one or more files using DotNetZip, and

  • 0

I have a method that zips up one or more files using DotNetZip, and it has been working correctly. I received an error for the first time today and it appears to be related to the total size of the archive. Using the same 60mb .tiff image, I would add a few extra copies, test, repeat. It worked fine until about 10 images were added, then, when I opened the Zip file using WinRar, I would get the “Unexpected end of archive” error. Testing in this manner, I believe I’ve ruled out the problem being related to my code or the files (being corrupt or something). The code does not error, only WinRar. When I open the Zip file, there is only one file displayed with a size of “0.” So it seems like some sort of size limit is being reached and it’s not allowing the archive to be created. I just don’t know which limit it is. Here is my code, if it helps:

HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = "application/zip";
HttpContext.Current.Response.AddHeader("content-disposition", "filename=" + "MyFileName" + DateTime.Now.ToString("MMddyyyy") + ".zip");

using (var zip = new Ionic.Zip.ZipFile())
{
    zip.MaxOutputSegmentSize = 819200; // I tried adding this and it did not fix the problem

    foreach (var file in files)
    {
        zip.AddFile(file.FileLocation, file.ZipFileDirectory).FileName = 
            (!string.IsNullOrEmpty(file.ZipFileDirectory) && (file.ZipFileDirectory != @"\")) ? 
                string.Format(@"{0}\{1}", file.ZipFileDirectory, file.FileName) : 
                file.FileName;
    }

    zip.Save(HttpContext.Current.Response.OutputStream);
}
  • 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-30T21:40:02+00:00Added an answer on May 30, 2026 at 9:40 pm

    Do you need to Flush the stream after your are done writing to it?

    HttpContext.Current.Response.Flush();

    EDIT:

    Call HttpContext.Current.ApplicationInstance.CompleteRequest()

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

Sidebar

Related Questions

I have a method that is receiving more than one parameter. The method signature
I have that method that counts files in a certain folder: private void countfiles(string
I have this method that downloads .csv files from yahoo finance and saves them
I have a method that accepts three NSMutableArrays, one as Input and two as
I have a method that can be called if the person has a specific
I have a method that executes inside one form, but I need to retrieve
I have a method that receives a customer object which has changed properties and
I have a method that has 2 output parameters. The method should take an
I have a method that I'm using to output all the class names in
I have class method that returns a list of employees that I can iterate

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.