Extract BZIP2
BZIP2, short for 'Burrows-Wheeler Block Sort Text Compressor,' is a file compression utility commonly used in Unix and Linux systems. As the name suggests, it is best suited for compressing individual text files.
To extract files from a BZIP2 archive, use the static ExtractArchiveToDirectory
method from the IronBZip2Archive class. This method requires the BZIP2 file path as the first parameter and the extraction directory as the second parameter. It's worth noting that both the file extension and the .bz2 extension are included in the file name. This is because, during compression, the file extension is removed, and during extraction, the method removes the .bz2 extension.
// Sample C# code to extract files from a BZIP2 archive
// Including necessary namespace for handling BZIP2 files
using IronBZip2;
public class BZip2ExtractionExample
{
public static void Main()
{
// Specify the path to the BZIP2 file
string bzip2FilePath = "path/to/yourfile.bz2";
// Specify the directory where you want to extract the files
string extractionDirectory = "path/to/destination/directory";
// Extract the BZIP2 archive to the specified directory
// This method extracts the contents of the BZIP2 file to the extraction directory.
IronBZip2Archive.ExtractArchiveToDirectory(bzip2FilePath, extractionDirectory);
// Inform the user that the extraction was successful.
Console.WriteLine("Extraction complete.");
}
}
// Note:
// - Ensure that 'IronBZip2.dll' is referenced in your project.
// - Handle any exceptions that may occur during the extraction process in production code.
// Sample C# code to extract files from a BZIP2 archive
// Including necessary namespace for handling BZIP2 files
using IronBZip2;
public class BZip2ExtractionExample
{
public static void Main()
{
// Specify the path to the BZIP2 file
string bzip2FilePath = "path/to/yourfile.bz2";
// Specify the directory where you want to extract the files
string extractionDirectory = "path/to/destination/directory";
// Extract the BZIP2 archive to the specified directory
// This method extracts the contents of the BZIP2 file to the extraction directory.
IronBZip2Archive.ExtractArchiveToDirectory(bzip2FilePath, extractionDirectory);
// Inform the user that the extraction was successful.
Console.WriteLine("Extraction complete.");
}
}
// Note:
// - Ensure that 'IronBZip2.dll' is referenced in your project.
// - Handle any exceptions that may occur during the extraction process in production code.
' Sample C# code to extract files from a BZIP2 archive
' Including necessary namespace for handling BZIP2 files
Imports IronBZip2
Public Class BZip2ExtractionExample
Public Shared Sub Main()
' Specify the path to the BZIP2 file
Dim bzip2FilePath As String = "path/to/yourfile.bz2"
' Specify the directory where you want to extract the files
Dim extractionDirectory As String = "path/to/destination/directory"
' Extract the BZIP2 archive to the specified directory
' This method extracts the contents of the BZIP2 file to the extraction directory.
IronBZip2Archive.ExtractArchiveToDirectory(bzip2FilePath, extractionDirectory)
' Inform the user that the extraction was successful.
Console.WriteLine("Extraction complete.")
End Sub
End Class
' Note:
' - Ensure that 'IronBZip2.dll' is referenced in your project.
' - Handle any exceptions that may occur during the extraction process in production code.