Extract BZIP2

BZIP2, the 'Burrows-Wheeler Block Sort Text Compressor,' is a file compression utility commonly used in Unix and Linux systems. As its name suggests, it is well-suited for compressing individual text files. While it is a popular format in these operating systems, there are instances where extraction can fail. This is often because decompressing large BZIP2 files requires more memory and CPU resources than other formats, or it may occur when the extraction library doesn't support nested archives, such as TAR files.

However, IronZIP supports all these formats, eliminating any compatibility issues. It also works on all major operating systems. Here’s a quick example of how to extract BZIP2 files.

Extracting BZIP2 File with C#

  1. using IronZip
  2. IronBZip2Archive.ExtractArchiveToDirectory("output.txt.bz2", "extracted");

Extracting BZIP2 Archive

We can easily access the functionalities of the IronZIP namespace in our project. Specifically, the IronBZIP2Archive class includes a method called ExtractArchiveToDirectory, which allows us to extract the contents of a BZIP2 file.

The ExtractArchiveToDirectory method in the IronBZIP2Archive class is designed to unpack the contents of a BZIP2 file into a specified directory. The first parameter required is the full path to the BZIP2 file, while the second parameter indicates the destination folder. Developers can rely on this process for both effectiveness and security.

It is important to note that both the original file extension and the .bz2 extension must be included in the file name. This is because the file extension is removed during the compression process, and the method also removes the .bz2 extension during extraction.

Learn how to Create, Read, and Extract ZIP files efficiently with C# in our comprehensive IronZIP tutorial!

Ready to Get Started?
Nuget Downloads 14,507 | Version: 2025.9 just released