# Premiers pas avec IronZIP
## IronZIP : Votre bibliothèque d'archivage tout-en-un pour .NET
**IronZIP** est une bibliothèque de compression et de décompression d'archives développée par Iron Software. En plus du format ZIP largement utilisé, il peut également gérer les formats TAR, GZIP et BZIP2.
### Bibliothèque de compression et décompression d'archive C#
1. [Téléchargez la bibliothèque C# pour la compression et la décompression de fichiers](https://www.nuget.org/packages/IronZip/)
2. Gérer les formats ZIP, TAR, GZIP et BZIP2
3. Personnalisez les niveaux de compression de 0 à 9
4. Extraire le contenu des archives compressées
5. Ajouter des fichiers aux archives ZIP existantes et générer de nouveaux fichiers ZIP
### Compatibilité
**IronZIP** est compatible avec plusieurs plateformes :
#### Prise en charge des versions .NET :
- **C#** , **VB.NET** , **F#**
- **.NET 7, 6** , 5 et Core 3.1+
- .NET Standard (2.0+)
- .NET Framework (4.6.2+)
#### Systèmes d'exploitation et environnements pris en charge :
- **Windows** (10+, Server 2016+)
- **Linux** (Ubuntu, Debian, CentOS, etc.)
- **macOS** (10+)
- **iOS** (12+)
- **Android** API 21+ (v5 " Lollipop ")
- **Docker** (Windows, Linux, Azure)
- **Azure** (VPS, application web, fonction)
- **AWS** (EC2, Lambda)
#### Prise en charge des types de projets .NET :
- **Web** (Blazor et WebForms)
- **Mobile** (Xamarin et MAUI)
- **Bureau** (WPF et MAUI)
- **Console** (Applications et bibliothèque)
## Installation
### Bibliothèque IronZIP
Pour installer le paquet IronZIP, utilisez la commande suivante dans votre terminal ou la console de votre Package Manager :
```shell
:ProductInstall
```
Vous pouvez également télécharger directement depuis le [site Web officiel d'IronZIP NuGet](https://www.nuget.org/packages/IronZip) .
Une fois installé, vous pouvez commencer en ajoutant `using IronZip;` au début de votre code C#.
## Application de la clé de licence
Ensuite, appliquez une licence valide ou une clé d'essai à IronZIP en assignant la clé de licence à la propriété LicenseKey de la classe License. Incluez le code suivant juste après l'instruction d'importation, avant d'utiliser toute méthode IronZIP :
```csharp
using IronZip;
// Apply your license key here
IronZip.License.LicenseKey = "YOUR_LICENSE_KEY";
```
## Exemples de code
### Créer un exemple d'archive
Créez un fichier ZIP en utilisant l'instruction `using`. À l'intérieur du bloc en utilisant, utilisez la méthode `AddArchiveEntry` pour importer des fichiers dans le fichier ZIP. Enfin, exportez le fichier ZIP avec la méthode `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");
}
}
}
```
### Décompresser une archive dans un dossier
Extrayez le contenu du fichier ZIP en utilisant la méthode `ExtractArchiveToDirectory`. Spécifiez le chemin d'accès au fichier ZIP cible et au répertoire d'extraction.
```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);
}
}
}
```
### Ajouter des fichiers à une archive existante
Passer le chemin du fichier ZIP au constructeur ouvrira le fichier ZIP. Utilisez la même méthode `AddArchiveEntry` pour ajouter des fichiers au ZIP ouvert et l'exporter avec la méthode `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");
}
}
}
```
## Licence et support disponibles
**IronZIP** est une bibliothèque payante; cependant, des licences d'essai gratuites sont également disponibles [ici](trial-license).
Pour plus d'informations sur Iron Software, veuillez consulter notre site web :[https://ironsoftware.com/](https://ironsoftware.com/)
Pour plus d'assistance et pour toute question, veuillez [contacter notre équipe](#live-chat-support) .
### Assistance d'Iron Software
Pour toute assistance générale et questions techniques, veuillez nous contacter par e-mail à l'adresse suivante :[support@ironsoftware.com](mailto:support@ironsoftware.com)
IronZIP : Votre bibliothèque d'archivage tout-en-un pour .NET
IronZIP est une bibliothèque de compression et de décompression d'archives développée par Iron Software. En plus du format ZIP largement utilisé, il peut également gérer les formats TAR, GZIP et BZIP2.
Bibliothèque de compression et décompression d'archive C#
Une fois installé, vous pouvez commencer en ajoutant using IronZip; au début de votre code C#.
Application de la clé de licence
Ensuite, appliquez une licence valide ou une clé d'essai à IronZIP en assignant la clé de licence à la propriété LicenseKey de la classe License. Incluez le code suivant juste après l'instruction d'importation, avant d'utiliser toute méthode 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"
Exemples de code
Créer un exemple d'archive
Créez un fichier ZIP en utilisant l'instruction using. À l'intérieur du bloc en utilisant, utilisez la méthode AddArchiveEntry pour importer des fichiers dans le fichier ZIP. Enfin, exportez le fichier ZIP avec la méthode 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
Décompresser une archive dans un dossier
Extrayez le contenu du fichier ZIP en utilisant la méthode ExtractArchiveToDirectory. Spécifiez le chemin d'accès au fichier ZIP cible et au répertoire d'extraction.
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
Ajouter des fichiers à une archive existante
Passer le chemin du fichier ZIP au constructeur ouvrira le fichier ZIP. Utilisez la même méthode AddArchiveEntry pour ajouter des fichiers au ZIP ouvert et l'exporter avec la méthode 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
Licence et support disponibles
IronZIP est une bibliothèque payante; cependant, des licences d'essai gratuites sont également disponibles ici.
Curtis Chau détient un baccalauréat en informatique (Université de Carleton) et se spécialise dans le développement front-end avec expertise en Node.js, TypeScript, JavaScript et React. Passionné par la création d'interfaces utilisateur intuitives et esthétiquement plaisantes, Curtis aime travailler avec des frameworks modernes et créer des manuels bien structurés et visuellement attrayants.