Premiers pas avec IronZIP

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

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 de décompression d'archives C

  1. Téléchargez la bibliothèque C# pour la compression et la décompression de fichiers
  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 gestionnaire de paquets :

Install-Package IronZip

Vous pouvez également télécharger directement depuis le site Web officiel d'IronZIP NuGet .

Une fois installé, vous pouvez commencer en ajoutant using IronZip; en haut de votre code C#.

Application de la clé de licence

Ensuite, appliquez une clé de licence ou d'essai valide à IronZIP en attribuant 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 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

Exemples de code

Créer un exemple d'archive

Créez un fichier ZIP en utilisant l'instruction using . Dans le bloc using, utilisez la méthode AddArchiveEntry pour importer les fichiers dans l'archive ZIP. Enfin, exportez l'archive ZIP avec la méthode 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

Décompresser une archive dans un dossier

Extrayez le contenu du fichier ZIP à l'aide de 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 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

Ajouter des fichiers à une archive existante

Le passage du chemin d'accès au fichier ZIP au constructeur permettra d'ouvrir ce dernier. Utilisez ensuite la méthode AddArchiveEntry pour ajouter des fichiers à l'archive ZIP ouverte et exportez-la avec la méthode 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

Licence et support disponibles

IronZIP est une bibliothèque payante, mais des licences d'essai gratuites sont également disponibles ici .

Pour plus d'informations sur Iron Software, veuillez consulter notre site web :https://ironsoftware.com/ Pour plus d'assistance et pour toute question, veuillez contacter notre équipe .

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

Curtis Chau
Rédacteur technique

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 ...

Lire la suite
Prêt à commencer?
Nuget Téléchargements 16,647 | Version: 2025.11 vient de sortir