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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:55:01+00:00 2026-06-10T03:55:01+00:00

With the SharpZip lib I can easily extract a file from a zip archive:

  • 0

With the SharpZip lib I can easily extract a file from a zip archive:

FastZip fz = new FastZip();
string path = "C:/bla.zip";
fz.ExtractZip(bla,"C:/Unzips/",".*");

However this puts the uncompressed folder in the output directory.
Suppose there is a foo.txt file within bla.zip which I want. Is there an easy way to just extract that and place it in the output directory (without the folder)?

  • 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-10T03:55:02+00:00Added an answer on June 10, 2026 at 3:55 am

    The FastZip does not seem to provide a way to change folders, but the “manual” way of doing supports this.

    If you take a look at their example:

    public void ExtractZipFile(string archiveFilenameIn, string outFolder) {
        ZipFile zf = null;
        try {
            FileStream fs = File.OpenRead(archiveFilenameIn);
            zf = new ZipFile(fs);
    
            foreach (ZipEntry zipEntry in zf) {
                if (!zipEntry.IsFile) continue; // Ignore directories
    
                String entryFileName = zipEntry.Name;
                // to remove the folder from the entry:
                // entryFileName = Path.GetFileName(entryFileName);
    
                byte[] buffer = new byte[4096];     // 4K is optimum
                Stream zipStream = zf.GetInputStream(zipEntry);
    
                // Manipulate the output filename here as desired.
                String fullZipToPath = Path.Combine(outFolder, entryFileName);
                string directoryName = Path.GetDirectoryName(fullZipToPath);
                if (directoryName.Length > 0)
                    Directory.CreateDirectory(directoryName);
    
                using (FileStream streamWriter = File.Create(fullZipToPath)) {
                    StreamUtils.Copy(zipStream, streamWriter, buffer);
                }
            }
        } finally {
            if (zf != null) {
                zf.IsStreamOwner = true;stream
                zf.Close();
            }
        }
    }
    

    As they note, instead of writing:

    String entryFileName = zipEntry.Name;
    

    you can write:

    String entryFileName = Path.GetFileName(entryFileName)
    

    to remove the folders.

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

Sidebar

Related Questions

I'm trying to create a Zip file from .Net that can be read from
Everything is working fine.. I can Unzip files, from an Zip/Rar .. Archive. The
I use DotNetZip to create a zip archive with an in memory string and
I'm trying to use SharpZipLib to pull specified files from a zip archive. All
I am using Sharpziplib version 0.86.0 to extract a zip file. It is working
I am using Sharpziplib version 0.86 to extract a zip file. It is working
How to extract specific file (or have streamed access) from tar.gz (tar files and
I am currently using the SharpZip api to handle my zip file entries. It
How can I create 7-Zip archives from my C# console application? I need to
I'm using SharpZipLib to create a zip file with an html page and images.

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.