Introducción a IronZIP
IronZIP: Su biblioteca de archivos todo en uno for .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
- Descarga la biblioteca C# para compresión y descompresión de archivos
- Maneja formatos ZIP, TAR, GZIP y BZIP2
- Personaliza niveles de compresión del 0 al 9
- Extrae contenido de archivos comprimidos
- 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, puede comenzar agregando using IronZip; en la parte superior de su 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"
Ejemplos de código
Crear un ejemplo de archivo
Cree un archivo ZIP utilizando la declaración using. Dentro del bloque using, use el método AddArchiveEntry para importar archivos al archivo ZIP. Finalmente, exporte 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
Desarchivar un archivo en una carpeta
Extraiga el contenido del archivo ZIP utilizando 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
Agregar archivos a un archivo existente
Al pasar la ruta del archivo ZIP al constructor, este se abrirá. Utilice el mismo método AddArchiveEntry para agregar archivos al archivo ZIP abierto y exportarlo 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
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

