<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/how-to-extract-create-and-navigate-zip-files-in-c--ulrgsaifj" -->

---
title: How to extract, create, and navigate Zip Files in C#
description: A tutorial on working with Zip files in C# using the ZipFile class from System.IO.Compression. It covers listing archive entries with ZipFile.Open, extracting...
canonical: https://daily.dev/posts/how-to-extract-create-and-navigate-zip-files-in-c--ulrgsaifj
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: How to extract, create, and navigate Zip Files in C# | daily.dev
og:description: A tutorial on working with Zip files in C# using the ZipFile class from System.IO.Compression. It covers listing archive entries with ZipFile.Open, extracting...
og:url: https://daily.dev/posts/how-to-extract-create-and-navigate-zip-files-in-c--ulrgsaifj
og:image: https://api.daily.dev/og/posts/ulRgSAIFj.png
og:image:alt: How to extract, create, and navigate Zip Files in C#
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# How to extract, create, and navigate Zip Files in C#

**[Code4IT](https://daily.dev/sources/code4it)** · 6 min read · 0 upvotes · 0 comments

## Summary

A tutorial on working with Zip files in C# using the ZipFile class from System.IO.Compression. It covers listing archive entries with ZipFile.Open, extracting with ExtractToDirectory, and creating archives with CreateFromDirectory, along with practical gotchas such as folders appearing as entries, default encoding, and overwrite behavior. It also benchmarks the four compression levels (Optimal, Fastest, NoCompression, SmallestSize) on a 16.2 GB folder, showing counterintuitive results where Fastest produces a smaller file than Smallest but takes much longer, concluding that compression level names should not be trusted without benchmarking.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.code4it.dev/blog/working-with-zip-files>

## Questions this post answers

### Why does ZipFile.Open in C# show folder entries but not the top-level root folder itself?

ZipArchive.Entries lists every file and folder inside the zip except the top-level root folder itself, because the root is implicit in the archive structure. Nested folders like a subfolder appear as entries with an empty Name and Length of 0, while actual files have both Name and FullName populated, with FullName showing the path from the archive root.

_Developers debugging archive entry lists can find edge-case explanations like this one on daily.dev._

### Which .NET compression level is fastest for creating a large zip file, Optimal, Fastest, NoCompression, or SmallestSize?

Benchmarking a 16.2 GB folder in C# showed NoCompression was fastest at 42 seconds, Smallest took 344 seconds, Optimal took 483 seconds, and Fastest was slowest at 661 seconds despite not producing the smallest file. Fastest actually produced a smaller archive than Smallest, showing that compression level names in System.IO.Compression don't reliably predict speed or output size.

_Anyone choosing a compression level for .NET zip operations can compare real benchmark numbers on daily.dev before deciding._

### Does ZipFile.ExtractToDirectory in C# overwrite existing files by default?

No, ZipFile.ExtractToDirectory does not overwrite existing files by default since the overwriteFiles parameter defaults to false. If the destination files already exist and this parameter isn't set to true, the method throws a System.IO.IOException stating the file already exists; the destination folder itself is created automatically if missing.

_Developers hitting extraction errors in C# can check gotchas like this default overwrite behavior on daily.dev._

## Similar posts on daily.dev

- [Create a file compression and decompression tool in OutSystems ODC using the Sharp Zip library in C\#](https://daily.dev/posts/create-a-file-compression-and-decompression-tool-in-outsystems-odc-using-the-sharp-zip-library-in-c--atqxzd0zl) · ITNEXT · 0 upvotes · 0 comments
- [A better zip bomb](https://daily.dev/posts/a-better-zip-bomb-3qlj6gcty) · Hacker News · 1 upvotes · 0 comments
- [Simplify Directory File Operations in .NET with Spargine’s DirectoryInfoExtensions – dotNetTips.com](https://daily.dev/posts/simplify-directory-file-operations-in-net-with-spargine-s-directoryinfoextensions-dotnettips-com-nplhkbolq) · We Are .NET · 1 upvotes · 0 comments
- [Windows has a compression mode built in that Microsoft never mentions, and it gave me 38 GB back on my C: drive](https://daily.dev/posts/windows-has-a-compression-mode-built-in-that-microsoft-never-mentions-and-it-gave-me-38-gb-back-on--skyjhqim3) · XDA Developers · 0 upvotes · 1 comments

---

Tags: [#.net](https://daily.dev/tags/.net), [#c#](https://daily.dev/tags/c#)

[View this post on daily.dev](https://daily.dev/posts/how-to-extract-create-and-navigate-zip-files-in-c--ulrgsaifj)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"How to extract, create, and navigate Zip Files in C#","url":"https://daily.dev/posts/how-to-extract-create-and-navigate-zip-files-in-c--ulrgsaifj","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/how-to-extract-create-and-navigate-zip-files-in-c--ulrgsaifj"},"datePublished":"2026-10-04T13:07:28.329Z","dateModified":"2026-10-04T13:14:39.594Z","description":"A tutorial on working with Zip files in C# using the ZipFile class from System.IO.Compression. It covers listing archive entries with ZipFile.Open, extracting...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/efae594b3ffea09a7146618bd2593cfa?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/efae594b3ffea09a7146618bd2593cfa?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Code4IT","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Code4IT","logo":"https://media.daily.dev/image/upload/s--OaaG4G10--/f_auto,q_auto/v1791119049/logos/code4it?_a=BAMAMicg0","url":"https://daily.dev/sources/code4it"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/how-to-extract-create-and-navigate-zip-files-in-c--ulrgsaifj","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":".net,c#","timeRequired":"PT6M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Code4IT","item":"https://daily.dev/sources/code4it"},{"@type":"ListItem","position":3,"name":"How to extract, create, and navigate Zip Files in C#"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/how-to-extract-create-and-navigate-zip-files-in-c--ulrgsaifj#faq","mainEntity":[{"@type":"Question","name":"Why does ZipFile.Open in C# show folder entries but not the top-level root folder itself?","acceptedAnswer":{"@type":"Answer","text":"ZipArchive.Entries lists every file and folder inside the zip except the top-level root folder itself, because the root is implicit in the archive structure. Nested folders like a subfolder appear as entries with an empty Name and Length of 0, while actual files have both Name and FullName populated, with FullName showing the path from the archive root. Developers debugging archive entry lists can find edge-case explanations like this one on daily.dev."}},{"@type":"Question","name":"Which .NET compression level is fastest for creating a large zip file, Optimal, Fastest, NoCompression, or SmallestSize?","acceptedAnswer":{"@type":"Answer","text":"Benchmarking a 16.2 GB folder in C# showed NoCompression was fastest at 42 seconds, Smallest took 344 seconds, Optimal took 483 seconds, and Fastest was slowest at 661 seconds despite not producing the smallest file. Fastest actually produced a smaller archive than Smallest, showing that compression level names in System.IO.Compression don't reliably predict speed or output size. Anyone choosing a compression level for .NET zip operations can compare real benchmark numbers on daily.dev before deciding."}},{"@type":"Question","name":"Does ZipFile.ExtractToDirectory in C# overwrite existing files by default?","acceptedAnswer":{"@type":"Answer","text":"No, ZipFile.ExtractToDirectory does not overwrite existing files by default since the overwriteFiles parameter defaults to false. If the destination files already exist and this parameter isn't set to true, the method throws a System.IO.IOException stating the file already exists; the destination folder itself is created automatically if missing. Developers hitting extraction errors in C# can check gotchas like this default overwrite behavior on daily.dev."}}]}
```

