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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:52:40+00:00 2026-06-01T13:52:40+00:00

I am using the library ICSharpCode.SharpZipLib.Zip ; My code is follows: The path is

  • 0

I am using the library ICSharpCode.SharpZipLib.Zip;

My code is follows:

  • The path is root. \\ALAWP\\THIS\\ACORD\\
  • I’m zipping them to the ZIPDirectory

However when it’s done the file is not named acord_combined.txt, instead it’s called ACORD\acord_combined.txt

What am I doing wrong?

public void CleanRoot()
{
    DirectoryInfo RootDi = new DirectoryInfo(FilePrep.RootDirectory);
    string ZipDirectory = FilePrep.RootDirectory + "\\processed\\AceKey"+ DateTime.Now.ToString("yyyyMMdd_H;mm;ss") +".zip";

    ZipOutputStream NewZipOutput = new ZipOutputStream(File.Create(ZipDirectory));

    foreach (FileInfo fi in RootDi.GetFiles("acord*.*"))
    {
        Compress(ref NewZipOutput, fi);
        //MoveFile(fi.FullName,ZipDirectory);
    }

    NewZipOutput.Finish();
    NewZipOutput.Close();
}

public void Compress(ref ZipOutputStream ZipFolder, FileInfo fi)
{
    try
    {
       FileStream fsFileToBeZipped = fi.OpenRead();

       ZipEntry entry = new ZipEntry(fi.FullName);
       ZipFolder.PutNextEntry(entry);
       int size = 2048;
       byte[] buffer = new byte[size];

       while (true)
       {
          size = fsFileToBeZipped.Read(buffer, 0, buffer.Length);

          if (size > 0)
             ZipFolder.Write(buffer, 0, size);
          else
             break;
       }   //end while ( true )

       fsFileToBeZipped.Close();

       //prepare and delete file
       fi.Attributes = FileAttributes.Normal;
       //fi.Delete();
   }   //end try
   catch (Exception e)
   {
        Console.WriteLine("Error zipping File.  Error - " + e.Message);
   }   //end catch
}
  • 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-06-01T13:52:42+00:00Added an answer on June 1, 2026 at 1:52 pm

    Your problem is right here

    new ZipEntry(fi.FullName);
    

    The argument to zipEntry is the path in the zip file, not the full path the compressed data comes from. Usually zip libraries, such as 7zip and SharpZip, expose a way to create an “entry path” but the actual data written to the zip is from the full path.

    Probably what you want is

     new ZipEntry(Path.GetFileName(fi.fullName))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have library code that uses ICSharpCode.SharpZipLib under the hood to make it easy
I am using the SharpZipLib open source .net library from www.icsharpcode.net My goal is
Am using Mediainfo library in my C# project,before start invoking this dll,i just ran
I am using zendgdata library for google calendar. I am getting this error while
I using library of Zend Framework and code php (no using struct zend, only
Im using this library to post an rss feed on my website. The question
Using this library, ZXing , we have a project at school in which we'll
I have integrated Facebook using library in my previous application and it works fine
i was using Iconv library on Ruby to convert encoding from UTF-8 to UTF-32,
I am using IText library to facilitate pdf export in an applet. During the

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.