Pierwsze kroki z IronZIP
IronZIP: Twoja uniwersalna biblioteka archiwów dla .NET
IronZIP jest biblioteką do kompresji i dekompresji archiwów opracowaną przez Iron Software. Oprócz powszechnie używanego formatu ZIP obsługuje również formaty TAR, GZIP i BZIP2.
C# Biblioteka do kompresji i dekompresji archiwów
- Pobierz bibliotekę C# do kompresji i dekompresji plików
- Obsługa formatów ZIP, TAR, GZIP i BZIP2
- Dostosowanie poziomów kompresji od 0 do 9
- Wyodrębnianie zawartości z archiwów skompresowanych
- Dodawanie plików do istniejących archiwów ZIP i generowanie nowych plików ZIP
Kompatybilność
IronZIP oferuje kompatybilność międzyplatformową z:
Wsparcie wersji .NET:
- C#, VB.NET, F#
- .NET 7, 6, 5 i Core 3.1+
- .NET Standard (2.0+)
- .NET Framework (4.6.2+)
Wsparcie dla systemów operacyjnych i środowisk:
- Windows (10+, Server 2016+)
- Linux (Ubuntu, Debian, CentOS, itd.)
- macOS (10+)
- iOS (12+)
- Android API 21+ (v5 "Lollipop")
- Docker (Windows, Linux, Azure)
- Azure (VPS, WebApp, Function)
- AWS (EC2, Lambda)
Wsparcie dla typów projektów .NET:
- Web (Blazor i WebForms)
- Mobile (Xamarin i MAUI)
- Desktop (WPF i MAUI)
- Konsolowe (Aplikacja & Biblioteka)
Instalacja
Biblioteka IronZIP
Aby zainstalować pakiet IronZIP, użyj następującej komendy w terminalu lub konsoli menedżera pakietów:
Install-Package IronZip
Alternatywnie, pobierz bezpośrednio ze strony oficjalnej IronZIP na NuGet.
Po zainstalowaniu możesz rozpocząć pracę, dodając using IronZip; na początku kodu C#.
Stosowanie klucza licencyjnego
Następnie, zastosuj ważną licencję lub klucz próbny do IronZIP, przypisując klucz licencyjny do właściwości LicenseKey klasy License. Załącz następujący kod zaraz po instrukcji importu, przed użyciem jakichkolwiek metod 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"
Przykłady kodu
Przykład tworzenia archiwum
Utwórz plik ZIP za pomocą instrukcji using. W bloku using użyj metody AddArchiveEntry, aby zaimportować pliki do pliku ZIP. Na koniec wyeksportuj plik ZIP za pomocą metody 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
Rozpakowanie archiwum do folderu
Wyodrębnij zawartość pliku ZIP przy użyciu metody ExtractArchiveToDirectory. Określ ścieżkę docelowego pliku ZIP i katalog docelowy operacji wyodrębniania.
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
Dodaj pliki do istniejącego archiwum
Przekazanie ścieżki do pliku ZIP do konstruktora spowoduje otwarcie pliku ZIP. Wykorzystaj tę samą metodę AddArchiveEntry, aby dodać pliki do otwartego pliku ZIP, a następnie wyeksportuj go za pomocą metody 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
Licencjonowanie i wsparcie dostępne
IronZIP jest płatną biblioteką; jednakże, darmowe licencje próbne są również dostępne tutaj.
Aby uzyskać więcej informacji o Iron Software, odwiedź naszą stronę internetową: https://ironsoftware.com/ W przypadku dodatkowego wsparcia i zapytań, proszę skontaktować się z naszym zespołem.
Wsparcie od Iron Software
W przypadku ogólnego wsparcia i pytań technicznych, prosimy o kontakt mailowy na adres: support@ironsoftware.com

