Introducción a IronZIP

This article was translated from English: Does it need improvement?
Translated
View the article in English

IronZIP: Su biblioteca de archivos todo en uno para .NET

IronZIP es una biblioteca de compresión y descompresión de archivos desarrollada por Iron Software. Además del formato ZIP ampliamente usado, también puede manejar TAR, GZIP y BZIP2.

Biblioteca de compresión y descompresión de archivos de C

  1. Descarga la biblioteca C# para compresión y descompresión de archivos
  2. Maneja formatos ZIP, TAR, GZIP y BZIP2
  3. Personaliza niveles de compresión del 0 al 9
  4. Extrae contenido de archivos comprimidos
  5. Agrega archivos a archivos ZIP existentes y genera nuevos archivos ZIP

Compatibilidad

IronZIP tiene compatibilidad con soporte multiplataforma con:

Compatibilidad con versiones .NET:

  • C#, VB.NET, F#
  • .NET 7, 6, 5, y Core 3.1+
  • .NET Standard (2.0+)
  • .NET Framework (4.6.2+)

Soporte de sistemas operativos y entornos:

  • Windows (10+, Server 2016+)
  • Linux (Ubuntu, Debian, CentOS, etc.)
  • macOS (10+)
  • iOS (12+)
  • API Android 21+ (v5 "Lollipop")
  • Docker (Windows, Linux, Azure)
  • Azure (VPS, WebApp, Function)
  • AWS (EC2, Lambda)

Compatibilidad con tipos de proyectos .NET:

  • Web (Blazor & WebForms)
  • Móvil (Xamarin & MAUI)
  • Escritorio (WPF & MAUI)
  • Consola (Aplicación y Biblioteca)

Instalación

Biblioteca IronZIP

Para instalar el paquete IronZIP, utiliza el siguiente comando en tu terminal o consola del administrador de paquetes:

Install-Package IronZip

Alternativamente, descárgalo directamente desde el sitio oficial de NuGet de IronZIP.

Una vez instalado, puedes comenzar agregando using IronZip; al principio de tu código C#.

Aplicar clave de licencia

A continuación, aplica una licencia válida o una clave de prueba a IronZIP asignando la clave de licencia a la propiedad LicenseKey de la clase License. Incluye el siguiente código justo después de la declaración de importación, antes de usar cualquier método de IronZIP:

using IronZip;

// Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
using IronZip;

// Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
Imports IronZip

' Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY"
$vbLabelText   $csharpLabel

Ejemplos de código

Crear un ejemplo de archivo

Crea un archivo ZIP usando la declaración using. Dentro del bloque using, usa el método AddArchiveEntry para importar archivos al archivo ZIP. Finalmente, exporta el archivo ZIP con el método SaveAs.

using IronZip;
using System.IO;

class Program
{
    static void Main()
    {
        // Create a new ZIP file
        using (var archive = new ZipArchive())
        {
            // Add a file to the archive
            archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt"));

            // Save the ZIP archive
            archive.SaveAs("archive.zip");
        }
    }
}
using IronZip;
using System.IO;

class Program
{
    static void Main()
    {
        // Create a new ZIP file
        using (var archive = new ZipArchive())
        {
            // Add a file to the archive
            archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt"));

            // Save the ZIP archive
            archive.SaveAs("archive.zip");
        }
    }
}
Imports IronZip
Imports System.IO

Friend Class Program
	Shared Sub Main()
		' Create a new ZIP file
		Using archive = New ZipArchive()
			' Add a file to the archive
			archive.AddArchiveEntry("example.txt", File.ReadAllBytes("path/to/example.txt"))

			' Save the ZIP archive
			archive.SaveAs("archive.zip")
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

Desarchivar un archivo en una carpeta

Extrae el contenido del archivo ZIP usando el método ExtractArchiveToDirectory. Especifica la ruta del archivo ZIP de destino y el directorio de extracción.

using IronZip;

class Program
{
    static void Main()
    {
        // path to the ZIP file and extraction directory
        string zipPath = "archive.zip";
        string extractPath = "extracted/";

        // Extract all files in the ZIP archive to the specified directory
        using (var archive = new ZipArchive(zipPath))
        {
            archive.ExtractArchiveToDirectory(extractPath);
        }
    }
}
using IronZip;

class Program
{
    static void Main()
    {
        // path to the ZIP file and extraction directory
        string zipPath = "archive.zip";
        string extractPath = "extracted/";

        // Extract all files in the ZIP archive to the specified directory
        using (var archive = new ZipArchive(zipPath))
        {
            archive.ExtractArchiveToDirectory(extractPath);
        }
    }
}
Imports IronZip

Friend Class Program
	Shared Sub Main()
		' path to the ZIP file and extraction directory
		Dim zipPath As String = "archive.zip"
		Dim extractPath As String = "extracted/"

		' Extract all files in the ZIP archive to the specified directory
		Using archive = New ZipArchive(zipPath)
			archive.ExtractArchiveToDirectory(extractPath)
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

Agregar archivos a un archivo existente

Pasar la ruta del archivo ZIP al constructor abrirá el archivo ZIP. Utiliza el mismo método AddArchiveEntry para agregar archivos al ZIP abierto y expórtalo con el método SaveAs.

using IronZip;
using System.IO;

class Program
{
    static void Main()
    {
        // Open an existing ZIP file
        using (var archive = new ZipArchive("archive.zip"))
        {
            // Add more files to the archive
            archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt"));

            // Save updates to the ZIP archive
            archive.SaveAs("archive.zip");
        }
    }
}
using IronZip;
using System.IO;

class Program
{
    static void Main()
    {
        // Open an existing ZIP file
        using (var archive = new ZipArchive("archive.zip"))
        {
            // Add more files to the archive
            archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt"));

            // Save updates to the ZIP archive
            archive.SaveAs("archive.zip");
        }
    }
}
Imports IronZip
Imports System.IO

Friend Class Program
	Shared Sub Main()
		' Open an existing ZIP file
		Using archive = New ZipArchive("archive.zip")
			' Add more files to the archive
			archive.AddArchiveEntry("anotherfile.txt", File.ReadAllBytes("path/to/anotherfile.txt"))

			' Save updates to the ZIP archive
			archive.SaveAs("archive.zip")
		End Using
	End Sub
End Class
$vbLabelText   $csharpLabel

Licencias y soporte disponibles

IronZIP es una biblioteca de pago, sin embargo, las licencias de prueba gratuitas también están disponibles aquí.

Para más información sobre Iron Software, por favor visita nuestro sitio web: https://ironsoftware.com/ Para más asistencia y consultas, por favor pregunta a nuestro equipo.

Soporte de Iron Software

Para soporte general y consultas técnicas, por favor envíanos un correo electrónico a: support@ironsoftware.com

Curtis Chau
Escritor Técnico

Curtis Chau tiene una licenciatura en Ciencias de la Computación (Carleton University) y se especializa en el desarrollo front-end con experiencia en Node.js, TypeScript, JavaScript y React. Apasionado por crear interfaces de usuario intuitivas y estéticamente agradables, disfruta trabajando con frameworks modernos y creando manuales bien ...

Leer más
¿Listo para empezar?
Nuget Descargas 16,647 | Version: 2025.11 recién lanzado