# Introducción a IronZIP
## 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 C#
1. [Descarga la biblioteca C# para compresión y descompresión de archivos](https://www.nuget.org/packages/IronZip/)
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:
```shell
:ProductInstall
```
Alternativamente, descárgalo directamente desde el [sitio oficial de NuGet de IronZIP](https://www.nuget.org/packages/IronZip).
Una vez instalado, puede comenzar agregando `using IronZip;` al principio de su código C#.
## Aplicar clave de licencia
A continuación, aplica una licencia válida o 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:
```csharp
using 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 instrucción `using`. Dentro del bloque using, utilice el método `AddArchiveEntry` para importar archivos en el archivo ZIP. Finalmente, exporte el archivo ZIP con el método `SaveAs`.
```csharp
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");
}
}
}
```
### 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.
```csharp
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);
}
}
}
```
### Agregar archivos a un archivo existente
Pasar la ruta del archivo ZIP al constructor abrirá el archivo ZIP. Utilice el mismo método `AddArchiveEntry` para agregar archivos al ZIP abierto y expórtelo con el método `SaveAs`.
```csharp
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");
}
}
}
```
## Licencias y soporte disponibles
**IronZIP** es una biblioteca de pago; sin embargo, también están disponibles licencias de prueba gratuitas [aquí](trial-license).
Para más información sobre Iron Software, por favor visita nuestro sitio web: [https://ironsoftware.com/](https://ironsoftware.com/)
Para más asistencia y consultas, por favor [pregunta a nuestro equipo](#live-chat-support).
### Soporte de Iron Software
Para soporte general y consultas técnicas, por favor envíanos un correo electrónico a: [support@ironsoftware.com](mailto:support@ironsoftware.com)
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 C#
Una vez instalado, puede comenzar agregando using IronZip; al principio de su código C#.
Aplicar clave de licencia
A continuación, aplica una licencia válida o 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 hereIronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
using IronZip;
// Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
ImportsIronZip' Apply your license key hereIronZip.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 instrucción using. Dentro del bloque using, utilice el método AddArchiveEntry para importar archivos en el archivo ZIP. Finalmente, exporte el archivo ZIP con el método SaveAs.
using IronZip;using System.IO;class Program{ static voidMain() { // 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");
}
}
}
ImportsIronZipImportsSystem.IOFriend Class ProgramShared Sub Main() ' Create a new ZIP fileUsing 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")EndUsing End SubEnd Class
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 voidMain() { // 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);
}
}
}
ImportsIronZipFriend Class ProgramShared Sub Main() ' path to the ZIP file and extraction directory Dim zipPath AsString = "archive.zip" Dim extractPath AsString = "extracted/" ' Extract all files in the ZIP archive to the specified directoryUsing archive = New ZipArchive(zipPath) archive.ExtractArchiveToDirectory(extractPath)EndUsing End SubEnd Class
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
Pasar la ruta del archivo ZIP al constructor abrirá el archivo ZIP. Utilice el mismo método AddArchiveEntry para agregar archivos al ZIP abierto y expórtelo con el método SaveAs.
using IronZip;using System.IO;class Program{ static voidMain() { // 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");
}
}
}
ImportsIronZipImportsSystem.IOFriend Class ProgramShared Sub Main() ' Open an existing ZIP fileUsing 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")EndUsing End SubEnd Class
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, también están disponibles licencias de prueba gratuitas aquí.
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 estructurados y visualmente atractivos.